Skip to content

Instantly share code, notes, and snippets.

@thoughtpolice
Created March 21, 2012 17:00
Show Gist options
  • Save thoughtpolice/2149553 to your computer and use it in GitHub Desktop.
Save thoughtpolice/2149553 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use Socket;
use IO::Handle;
$port=3389;
$host='127.0.0.1';
$packhost=inet_aton($host);
$address=sockaddr_in($port,$packhost);
socket(SERVER, AF_INET, SOCK_STREAM, getprotobyname('tcp'));
bind(SERVER, $address);
listen(SERVER, 10);
$payl0ad = pack("C11", 0x03, 0x00, 0x00, 0x0b # TPKT: ver 3, 11 byte response
, 0x06 # X.224: length
, 0xd0 # X.224: connection code/credit
, 0x00, 0x00 # X.224: dest ref
, 0x12, 0x34 # X.224: source ref (bogus)
, 0x00 # X.224: class & options
);
print "starting up server...\n";
while( 1 ) {
print "zomg\n";
next unless (accept(CLIENT,SERVER));
print "accepted client\n";
send(CLIENT,$payl0ad,0);
close CLIENT;
}
close SERVER;
exit 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment