Skip to content

Instantly share code, notes, and snippets.

@shwangdev
Created March 7, 2012 10:19
Show Gist options
  • Save shwangdev/1992395 to your computer and use it in GitHub Desktop.
Save shwangdev/1992395 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import time
import threading
import urllib
import httplib2
import re
sum = 10
concurrent = 1
CONSTANT = 0
class upload(threading.Thread):
def __init__(self, threadName):
threading.Thread.__init__(self, name = threadName)
#self.AT='74jf%2Bm8A2kis8w%3D%3D'
self.AT='295F+G8A3KBoSg=='
#self.AT='62bt+m8AyDHRGg=='
#self.ID='000000000000000000000000000000000001'
self.IDPrefix = '0000000000000000000000000000000000' # 2 bit tructed
#self.PN='1300000001'
self.PNPrefix = '139000000'
self.PolicyServerIP = '10.64.66.144'
self.PolicyServerPort = '8080'
self.threadName = threadName
if len(self.threadName) == 1 :
self.ID = self.IDPrefix + '0' + str(self.threadName)
self.PN = self.PNPrefix + '0' + str(self.threadName)
elif len ( self.threadName ) == 2 :
self.ID = self.IDPrefix + str(self.threadName)
self.PN = self.PNPrefix + str( self.threadName)
self.register(self.threadName)
def register(self,name):
http=httplib2.Http()
# https://10.64.66.92:8080/officescan/PLS_TMMS_CGI/cgiOsmaOnStart.dll?AT=&VR=1&ID=35643504-5060-8019-35BB-1C077A91552D&HN=devil&OT=71&OV=2.3.3&SV=7.1.0.1114&FV=&EV=7.1.0.1114&PV=111100&ENV=&SIM=1&PN=&USERNAME=%21CRYPT%2141C26AD8F92A74D4D279ADF9E8149874BC57CFD7F15033B5D2BA1C58560D8D55E556D340155&PASSWORD=%21CRYPT%2120D13DF394D7C6926CE625EA1359D626062781A4306
url = 'http://' + self.PolicyServerIP + ':' +self.PolicyServerPort + '/officescan/PLS_TMMS_CGI/cgiOsmaOnStart.dll?AT=&VR=1&ID='+ self.ID + '&HN='+ self.PN + '&OT=2.3.3&SV=7.1.0.1114&FV=&EV=7.1.0.1114&PV=111100&ENV=&SIM=1&PN=&USERNAME=%21CRYPT%2141C26AD8F92A74D4D279ADF9E8149874BC57CFD7F15033B5D2BA1C58560D8D55E556D340155&PASSWORD=%21CRYPT%2120D13DF394D7C6926CE625EA1359D626062781A4306'
req,content = http.request(url,'GET')
def postHttpRequest(self):
http = httplib2.Http()
url = 'http://'+ self.PolicyServerIP+':' + self.PolicyServerPort+ '/officescan/PLS_TMMS_CGI/cgiOsmaLog.dll'
#body='AT={AT}&VR=1&ID={ID}&TY=1&DT=1322116457&VN=Eicar_test_file&VT=5&FN=TestEicar&AC=13&RS=2&PN={PN}\n'
#body= 'AT=' + self.AT + '&VR=1&ID=' + self.ID + '&TY=1&DT=1322116457&VN=Eicar_test_file&VT=5&FN=TestEicar&AC=13&RS=2&PN=' + self.PN + '\n'
headers = {'Content-type': 'text/plain'}
#body = ( [ ('AT',self.AT), ('VR','1'), ('ID',self.ID), ('TY',1),('DT','1322116457'), ('VN', 'Eicar_test_file') ,( 'VT',5), ('FN','TestEicar'), ('AC', '13'), ('RS','2'),('PN',self.PN)])
body = ( [ ('AT',self.AT), ('VR','1'), ('ID',self.ID), ('TY',1),('DT','1322116457'), ('VN', 'Eicar_test_file') ,( 'VT',5), ('FN','TestEicar'), ('AC', '13'), ('RS','2'),('PN',self.PN)])
#print body
#print urllib.urlencode(body)
response, content = http.request(url, 'POST', headers=headers, body=urllib.urlencode(body))
#print content
text=''
for i in content:
if ( i !=' ' and i !='\n' and i !='\r'):
text += i
global CONSTANT
if (text.find('RC=1') > 0 ):
CONSTANT = CONSTANT +1
def run(self):
print("%s started!" % self.getName()) # "Thread-x started!"
for x in range(concurrent) :
self. postHttpRequest()
print("%s finished!" % self.getName()) # "Thread-x finishsed!"
if __name__ == '__main__':
for x in range(sum/concurrent): # Four times...
mythread = upload("%d" % (x + 1)) #
mythread.start() # ...Start the thread
time.sleep(.9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment