Protostar net3
This level is at / opt/protostar/bin/net3 * /
Srandom (time (NULL))
Run (fd)
}
At first glance, it's a long code, but you still have to read ~: -) the program first reads a length, which is the length of the string to be sent by the client later. When you get a string the second time, you first judge whether the value of the first character is 23. If so, continue and then analyze the get_string () function. Read the first character, which also means length. Then take out the characters of that length and save them in the pointer. If the characters taken out three times are net3,awesomesauce,password, you can success them. Here is the code:
#! / usr/bin/env python
From socket import *
From struct import *
From optparse import OptionParser
Import select
Def main (hostname,port):
S = socket (AF_INET,SOCK_STREAM)
S.connect ((hostname,port))
Send_str = ("\ x17")
"\ x05net3\ x00"
"\ x0dawesomesauce\ x00"
"\ x09password\ x00")
Send_len = len (send_str)
S.send (pack ("> H", send_len))
S.send (send_str)
Print s.recv (1024)
S.close ()
If _ _ name__== "_ _ main__":
Parse = OptionParser ("usage:% prog [options]")
Parse.add_option ("- H", dest= "hostname", default= "127.0.0.1", type= "string", help= "The ip of the target")
Parse.add_option ("- P", dest= "port", default=2996,type= "int", help= "The port of the host")
(options,args) = parse.parse_args ()
Main (options.hostname,options.port)
Running result: