Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ pip3 install -r requirements.txt

## Usage
```
usage: Xdecrypt.py [-h] [-s SID] [-p PASSWORD]

usage: Xdecrypt.py [-h] [-u USERNMAE] [-s SID] [-p PASSWORD]
xsh, xfp password decrypt

```
optional arguments:
-h, --help show this help message and exit
-s SID, --sid SID `username`+`sid`, user `whoami /user` in command.
-u USER, --user USER `username`,`whoami` in command.
-s SID, --sid SID `sid`,`whoami /user` in command.
-p PASSWORD, --password PASSWORD
the password in sessions or path of sessions
```

-v VERSION, --version VERSION
xshell's version
```
$ whoami /user
用户信息
Expand All @@ -43,7 +43,7 @@ Host: 192.168.1.2:22
Username: root
Password: test

$ python3 Xdecrypt.py -s username+sid -p "D:\somewhere\NetSarang Computer"
$ python3 Xdecrypt.py -u username -s sid -p "D:\somewhere\NetSarang Computer"
=============D:\somewhere\NetSarang Computer\6\Xftp\Sessions\192.168.1.2.xfp=============
Host: 192.168.1.2:22
Username: root
Expand All @@ -57,6 +57,6 @@ Host: 192.168.1.2:22
Username: root
Password: test

$ python Xdecrypt.py -s username+sid -p password
$ python Xdecrypt.py -u username -s sid -p password
test
```
```
12 changes: 7 additions & 5 deletions Xdecrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ def decrypt_string(a1, a2):

config_path = ""
parser = argparse.ArgumentParser(description="xsh, xfp password decrypt")
parser.add_argument("-s", "--sid", default="", type=str, help="`username`+`sid`, user `whoami /user` in command.")
parser.add_argument("-u", "--user", default="", type=str, help="`username`,`whoami` in command.")
parser.add_argument("-s", "--sid", default="", type=str, help="`sid`,`whoami /user` in command.")
parser.add_argument("-p", "--password", default="", type=str, help="the password in sessions or path of sessions")
parser.add_argument("-v","--version",default="",type=str,help="xshell's version")
args = parser.parse_args()

if not args.password:
Expand All @@ -44,12 +46,13 @@ def decrypt_string(a1, a2):
args.sid = tmp[::-1]
else:
args.sid = GetUserName() + ConvertSidToStringSid(LookupAccountName(GetComputerName(), GetUserName())[0])

if not os.path.isdir(args.password):
r = decrypt_string(args.sid, args.password)
if args.version == "7":
r = decrypt_string(args.sid[::-1] + args.user, args.password)
else:
r = decrypt_string(args.user+args.sid, args.password)
if r:
print(r)

for root, dirs, files in os.walk(args.password):
for f in files:
if f.endswith(".xsh") or f.endswith(".xfp"):
Expand All @@ -59,7 +62,6 @@ def decrypt_string(a1, a2):
cfg.read(filepath)
except UnicodeDecodeError:
cfg.read(filepath, encoding="utf-16")

try:
if f.endswith(".xsh"):
host = "{}:{}".format(cfg["CONNECTION"]["Host"], cfg["CONNECTION"]["Port"])
Expand Down