Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

HELP: Script to gather IP Address from .RDP then compile to .exe for VNC

authentication

  • Please log in to reply
69 replies to this topic

#1 Panarchy

Panarchy

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 247 posts

Posted 05 June 2009 - 06:28 PM

Hi

I need some help creating a script that can gather IP Address from within .RDP or .vRD files, then output to the IP Address to a text file.

I then need that IP Address from that text file to be automatically inputted into a .cpp file, subsequently compiled and given the same name as the .RDP or .vRD file.

The .cpp file is basically a batch file (without the Command-Prompt window) which launches vnc viewer (UltraVNC) with username and password, unlike .VNC files which are limited to password ONLY authentication. This dual authentication is achieved using the following;
vncviewer.exe /connect xx.xx.xx.xx:5900 /user USERID /password PASSWORD

lscrat was used to do the /connect etc.

Please give me an example of a script which can gather the IP Address & Name from .RDP or .vRD files, then input both the IP Address & Name into a logfile, subsequently copying the IP Address into a .cpp file, compiling it, then renaming the *.exe to the name which correlates to the IP Address.

Thanks in advance,

Panarchy
  • 0

#2 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 05 June 2009 - 11:16 PM

You want to use regular expressions. I'd use Perl for this just because I like its regex and because I don't know how to use them in other languages. I'm sure that there's someone out there who knows how to use them in C/C++ better than I.
  • 0

#3 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 06 June 2009 - 11:30 AM

boost::regex has perl-style regular expressions and is well-documented.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#4 Panarchy

Panarchy

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 247 posts

Posted 06 June 2009 - 03:34 PM

dargueta & WingedPanther: I don't care which language it is (heck, choose Delphi or Assembly!!!), as long as it works. Doesn't need to have an interpreter/environment for Windows, just as long as the end product (the *.exe) is compatible with Windows.

So please try your best, to give me a coding example which exports both the name and IP Address from .RDP or .vRD files, into a .cpp file, subsequently compiling that with the name & IP Address of the .RDP or .vRD file.

Thanks in advance,

Panarchy
  • 0

#5 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 06 June 2009 - 04:23 PM

What exactly do you mean by "exporting into a .cpp file"?
  • 0

#6 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 06 June 2009 - 05:34 PM

I'm not familiar with the .RDP or .VRD file format. Getting that would be the first step.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#7 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 06 June 2009 - 05:48 PM

I suspect that they're formatted like .INI files, but I'm not sure. Could you send us a sample file?
  • 0

#8 Panarchy

Panarchy

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 247 posts

Posted 06 June 2009 - 06:06 PM

By exporting to an .cpp, I mean inputting data to the exact line of the IP Address, changing it, then compiling.

A friend has them stored in a .csv file though, I'm just waiting for him to send it to me, then I'll give you a copy.

In the meantime, can you predict how it would work?

Thanks in advance,

Panarchy
  • 0

#9 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 06 June 2009 - 06:15 PM

Probably pattern matching and replacing. I found a pretty good tutorial on regular expressions you might want to look at.
  • 0

#10 ikonia

ikonia

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 07 June 2009 - 06:22 AM

if your friend has the info on a cvs file would it not be more useful to use something like excel and a vb style macro to filter them out into different files ?

Or as suggested if you have it in a cvs file, do a while loop in perl and then use the substitute functionality within perl to find and replace the old ip address with the next one then issue the compiler function before moving ontot he next loop.
  • 0

#11 Panarchy

Panarchy

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 247 posts

Posted 07 June 2009 - 05:20 PM

Thanks for you suggestions ikonia.

I have no idea how the .csv file is stuctured. Once he has given me the .csv file, I'll post an [edited] copy of it here.

ikonia: The 2nd method you mentioned, how would I put the name in the /out: parameter, automatically?

Also, speed doesn't matter. Even if it takes 24 hours to complete, well whatever.

I'll try and get the .csv file again, sorry for the wait.

Panarchy
  • 0

#12 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 07 June 2009 - 06:10 PM

CSV - Comma-delimited text file. Basically one record per line, fields are separated by commas. You could use a printf() call for the /OUT: parameter.
  • 0





Also tagged with one or more of these keywords: authentication

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download