2014-12-24 13:37:31 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
This is the web client code
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import urllib2
|
|
|
|
|
|
|
|
|
|
|
|
class Client:
|
|
|
|
|
|
|
|
def __init__(self, cli_object):
|
|
|
|
self.data_to_transmit = ''
|
|
|
|
self.remote_server = cli_object.ip
|
|
|
|
self.protocol = "http"
|
2015-05-16 02:11:21 +00:00
|
|
|
if cli_object.file is None:
|
|
|
|
self.file_transfer = False
|
|
|
|
else:
|
|
|
|
if "/" in cli_object.file:
|
|
|
|
self.file_transfer = cli_object.file.split("/")[-1]
|
|
|
|
else:
|
|
|
|
self.file_transfer = cli_object.file
|
2014-12-24 13:37:31 +00:00
|
|
|
|
|
|
|
def transmit(self, data_to_transmit):
|
2015-05-16 02:11:21 +00:00
|
|
|
|
|
|
|
if not self.file_transfer:
|
2015-12-03 19:48:45 +00:00
|
|
|
url = "http://" + self.remote_server + ":" + self.port + "/post_data.php"
|
2015-05-16 02:11:21 +00:00
|
|
|
|
|
|
|
# Post the data to the web server at the specified URL
|
|
|
|
try:
|
|
|
|
f = urllib2.urlopen(url, data_to_transmit)
|
|
|
|
f.close()
|
|
|
|
print "[*] File sent!!!"
|
|
|
|
except urllib2.URLError:
|
|
|
|
print "[*] Error: Web server may not be active on " + self.remote_server
|
|
|
|
print "[*] Error: Please check server to make sure it is active!"
|
|
|
|
sys.exit()
|
|
|
|
else:
|
|
|
|
url = "http://" + self.remote_server + "/post_file.php"
|
|
|
|
|
|
|
|
try:
|
|
|
|
data_to_transmit = self.file_transfer + ".:::-989-:::." + data_to_transmit
|
|
|
|
f = urllib2.urlopen(url, data_to_transmit)
|
|
|
|
f.close()
|
|
|
|
print "[*] File sent!!!"
|
|
|
|
except urllib2.URLError:
|
|
|
|
print "[*] Error: Web server may not be active on " + self.remote_server
|
|
|
|
print "[*] Error: Please check server to make sure it is active!"
|
|
|
|
sys.exit()
|
|
|
|
|
2014-12-24 13:37:31 +00:00
|
|
|
return
|