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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.