Jump to content

parse rdp file


shocker-z

Recommended Posts

Hi what would you reccomend as being the best way to parse a rdp file?

here is an example of the file:

[code]screen mode id:i:2
desktopwidth:i:1024
desktopheight:i:768
session bpp:i:16
winposstr:s:0,3,0,0,800,600
full address:s:127.0.0.1
compression:i:1
keyboardhook:i:2
audiomode:i:0
redirectdrives:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
displayconnectionbar:i:1
autoreconnection enabled:i:1
username:s:administrator
domain:s:MyDomain
alternate shell:s:
shell working directory:s:
disable wallpaper:i:1
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
[/code]


So what i actually want is to grab the IP and Domain name but the files change format as in extra lines could be added so i can't just use line number.


Regards
Liam (Getting rusty on PHP)
Link to comment
https://forums.phpfreaks.com/topic/36337-parse-rdp-file/
Share on other sites

Could do with some cleaning, but it'll get you started....

[code]
<?php
  function getrdpinfo($rdp) {
    $lines = file($rdp);
    foreach ($lines as $line) {
      $tmp = explode(':',$line) {
      if ($tmp[0] == "domain") {
        $return['domain'] = $tmp[2];
      }
      if ($tmp[0] == "full address") {
        $return['ip'] = $tmp[2];
      }
    }
    return $return;
  }
 
  $result = getrdpinfo('file.rdp');
  echo $result['domain'];
  echo $result['ip'];

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/36337-parse-rdp-file/#findComment-172765
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.