Skip to content

Instantly share code, notes, and snippets.

@miettal
Created October 6, 2015 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miettal/09a0ae19cba6f6d0ef44 to your computer and use it in GitHub Desktop.
Save miettal/09a0ae19cba6f6d0ef44 to your computer and use it in GitHub Desktop.
misc200.py
#!/usr/bin/env python
# coding:utf-8
#
# misc400.py
#
# Author: Hiromasa Ihara (miettal)
# Created: 2015-10-03
#
import socket
import sys
import time
import test2
import os
host = "10.13.37.10"
port = 80
reqt = (""
"POST / HTTP/1.1\r\n"
"Host: 10.13.37.10\r\n"
"Connection: keep-alive\r\n"
"Content-Length: LENGTH\r\n"
"Cache-Control: max-age=0\r\n"
"Upgrade-Insecure-Requests: 1\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Accept-Language: ja,en-US;q=0.8,en;q=0.6\r\n"
"Cookie: PHPSESSID=hoge\r\n"
"\r\n"
"captcha=PARAM&submit=Send")
if __name__ == "__main__":
while True :
os.system("curl -H 'Cookie: PHPSESSID=hoge' http://10.13.37.10/captcha.php -o image.png 2> /dev/null")
result = test2.analysis('image.png')
#認識に失敗したら再読み込み
if len(result) != 6 : continue
print "result:"+result
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect((host, port))
req = reqt.replace('PARAM', result).replace('LENGTH', str(len(result)+20))
sock.send(req)
time.sleep(0.1)
msg = sock.recv(2048).split('\r\n\r\n')[2].split('<')[0].strip()
print msg
if msg.find("didn't") != -1 :
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment