#!/usr/bin/env python
from socket import *
from struct import *
from optparse import OptionParser
def main(hostname,port):
s = socket(AF_INET,SOCK_STREAM)
s.connect((hostname,port))
result = 0
for i in range(4):
rec = s.recv(4)
num = unpack("<I",rec)[0]
print "num[%d]:%d"%(i,num)
result += num
print str(result)
s.send(pack("<I",result))
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=2997,type="int",help="The port of the host")
(options,args)=parse.parse_args()
main(options.hostname,options.port)