-
Notifications
You must be signed in to change notification settings - Fork 289
Migrate to Python 3 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
hugsy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff, some things to change before merge
| def runtime_exec(jdwp, args): | ||
| print ("[+] Targeting '%s:%d'" % (args.target, args.port)) | ||
| print ("[+] Reading settings for '%s'" % jdwp.version) | ||
| print(("[+] Targeting '%s:%d'" % (args.target, args.port))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double parenthesis, also if we jump to Py 3.9 might as well use more goodies: here f-strings
| print(("[+] Targeting '%s:%d'" % (args.target, args.port))) | |
| print(f"[+] Targeting '{args.target}:{args.port}'") |
| print ("[+] Targeting '%s:%d'" % (args.target, args.port)) | ||
| print ("[+] Reading settings for '%s'" % jdwp.version) | ||
| print(("[+] Targeting '%s:%d'" % (args.target, args.port))) | ||
| print(("[+] Reading settings for '%s'" % jdwp.version)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[+] Reading settings for '%s'" % jdwp.version)) | |
| print(f"[+] Reading settings for '{jdwp.version}'") |
| print ("[-] Cannot find method Runtime.getRuntime()") | ||
| return False | ||
| print ("[+] Found Runtime.getRuntime(): id=%x" % getRuntimeMeth["methodId"]) | ||
| print(("[+] Found Runtime.getRuntime(): id=%x" % getRuntimeMeth["methodId"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[+] Found Runtime.getRuntime(): id=%x" % getRuntimeMeth["methodId"])) | |
| print("[+] Found Runtime.getRuntime(): id={getRuntimeMeth['methodId']:x}") |
| c = jdwp.get_class_by_name( args.break_on_class ) | ||
| if c is None: | ||
| print("[-] Could not access class '%s'" % args.break_on_class) | ||
| print(("[-] Could not access class '%s'" % args.break_on_class)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[-] Could not access class '%s'" % args.break_on_class)) | |
| print(f"[-] Could not access class '{args.break_on_class}'") |
| m = jdwp.get_method_by_name( args.break_on_method ) | ||
| if m is None: | ||
| print("[-] Could not access method '%s'" % args.break_on) | ||
| print(("[-] Could not access method '%s'" % args.break_on)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[-] Could not access method '%s'" % args.break_on)) | |
| print(f"[-] Could not access method '{args.break_on}'") |
| print("[-] Failed to invoke Runtime.getRuntime()") | ||
| return False | ||
| print ("[+] Runtime.getRuntime() returned context id:%#x" % rt) | ||
| print(("[+] Runtime.getRuntime() returned context id:%#x" % rt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[+] Runtime.getRuntime() returned context id:%#x" % rt)) | |
| print(f"[+] Runtime.getRuntime() returned context id:{rt:#x}") |
| print ("[-] Cannot find method Runtime.exec()") | ||
| return False | ||
| print ("[+] found Runtime.exec(): id=%x" % execMeth["methodId"]) | ||
| print(("[+] found Runtime.exec(): id=%x" % execMeth["methodId"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[+] found Runtime.exec(): id=%x" % execMeth["methodId"])) | |
| print(f"[+] found Runtime.exec(): id={execMeth['methodId']:x}") |
|
|
||
| retId = jdwp.unformat(jdwp.objectIDSize, buf[1:1+jdwp.objectIDSize]) | ||
| print ("[+] Runtime.exec() successful, retId=%x" % retId) | ||
| print(("[+] Runtime.exec() successful, retId=%x" % retId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[+] Runtime.exec() successful, retId=%x" % retId)) | |
| print(f"[+] Runtime.exec() successful, retId={retId:x}") |
| except Exception as e: | ||
| print ("[-] Exception: %s" % e) | ||
| traceback.print_exc() | ||
| print(("[-] Exception: %s" % e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| print(("[-] Exception: %s" % e)) | |
| print(f"[-] Exception: {str(e)}") |
| # JDWP protocol variables | ||
| # | ||
| HANDSHAKE = "JDWP-Handshake" | ||
| HANDSHAKE = b"JDWP-Handshake" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also edit the README too to mention the script requires Python3 (tested on Python 3.9)?
Greetings, jdwp-shellifier will still happily hand over shell in 2021 although Python 2 is getting harder to find. I managed to get system info and commands executed under Python 3.9 and while breaking on default java.net.ServerSocket.accept method.