-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRdiaswinv2.ps1
1040 lines (909 loc) · 50.2 KB
/
Rdiaswinv2.ps1
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
function Show-ComputerInfo {
$usuario = $env:USERNAME
$nomeComputador = $env:COMPUTERNAME
$ip = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.InterfaceAlias -notlike "*Loopback*" }).IPAddress
$portasTCP = (Get-NetTCPConnection -State Listen).Count
$portasUDP = (Get-NetUDPEndpoint).Count
$portasPerigosas = @(21, 22, 23, 25, 53, 80, 110, 135, 139, 143, 443, 445, 3389, 8080)
$portasAbertasPerigosas = Get-NetTCPConnection -State Listen | Where-Object { $portasPerigosas -contains $_.LocalPort } | Select-Object LocalPort
$sistemaOperacional = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty Caption
$usuarios = Get-LocalUser | Measure-Object | Select-Object -ExpandProperty Count
$memoriaRAM = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -ExpandProperty TotalPhysicalMemory
$memoriaRAMGB = [math]::Round($memoriaRAM / 1GB, 2)
$disco = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object Size, FreeSpace
$espacoTotalGB = [math]::Round($disco.Size / 1GB, 2)
$espacoLivreGB = [math]::Round($disco.FreeSpace / 1GB, 2)
$cpu = Get-CimInstance -ClassName Win32_Processor | Select-Object -ExpandProperty Name
$ultimaInicializacao = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
$firewallStatus = (Get-NetFirewallProfile | Where-Object { $_.Enabled -eq $true }).Count -gt 0
$updateStatus = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update").AUOptions
$antivirusStatus = (Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntivirusProduct).productState -ne $null
$bitlockerStatus = (Get-BitLockerVolume -MountPoint "C:").ProtectionStatus -eq "On"
$uacStatus = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System").EnableLUA -eq 1
Write-Host "`n=== Informacoes do Computador ===" -ForegroundColor Cyan
Write-Host "`n [Usuario]" -ForegroundColor Yellow
Write-Host "Usuario atual: $usuario"
Write-Host "`n [Rede]" -ForegroundColor Yellow
Write-Host "Nome do computador: $nomeComputador"
Write-Host "Endereco IP: $ip"
Write-Host "Portas TCP abertas: $portasTCP"
Write-Host "Portas UDP abertas: $portasUDP"
if ($portasAbertasPerigosas) {
Write-Host "Portas potencialmente perigosas abertas: " -ForegroundColor Red -NoNewline
Write-Host ($portasAbertasPerigosas.LocalPort -join ", ") -ForegroundColor Red
} else {
Write-Host "Portas potencialmente perigosas abertas: Nenhuma" -ForegroundColor Green
}
Write-Host "`n [Sistema]" -ForegroundColor Yellow
Write-Host "Sistema Operacional: $sistemaOperacional"
Write-Host "Quantidade de usuarios no sistema: $usuarios"
Write-Host "Ultima inicializacao do sistema: $ultimaInicializacao"
Write-Host "`n [Hardware]" -ForegroundColor Yellow
Write-Host "Processador (CPU): $cpu"
Write-Host "Memoria RAM total: $memoriaRAMGB GB"
Write-Host "Espaco em disco (C:):"
Write-Host " - Total: $espacoTotalGB GB"
Write-Host " - Livre: $espacoLivreGB GB"
Write-Host "`n [Seguranca]" -ForegroundColor Yellow
Write-Host "Firewall ativo: $(if ($firewallStatus) { 'Sim' } else { 'Nao' })"
Write-Host "Atualizacoes automaticas: $(if ($updateStatus -eq 4) { 'Sim' } else { 'Nao' })"
Write-Host "Antivirus instalado e ativo: $(if ($antivirusStatus) { 'Sim' } else { 'Nao' })"
Write-Host "BitLocker ativado: $(if ($bitlockerStatus) { 'Sim' } else { 'Nao' })"
Write-Host "UAC (Controle de Conta de Usuario) ativado: $(if ($uacStatus) { 'Sim' } else { 'Nao' })"
Write-Host "`n===============================`n" -ForegroundColor Cyan
$detalhes = Read-Host "`n`nVoce deseja obter informacoes mais detalhadas? (1/0)"
if ($detalhes -eq "1") {
Get-ComputerInfo | Format-List *
}
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
Clear-Host
}
function Show-UserInfo {
function Show-Menu {
Clear-Host
Write-Host "`n`n`n`n`n`n=====================================================" -ForegroundColor Cyan
Write-Host " === Menu de Informacoes de Usuarios === " -ForegroundColor Cyan
Write-Host "=====================================================" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 1. Listar Usuarios ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 2. Visualizar Informacoes de um Usuario ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 3. Exibir Grupos ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 4. Criar um Usuario ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 5. Escalar Privilegios ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 6. Deletar um Usuario ( CUIDADO !!!) ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 7. Mostrar Usuarios Logados ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "|| 8. Voltar ao menu inicial ||" -ForegroundColor Cyan
Write-Host "|| ||" -ForegroundColor Cyan
Write-Host "=====================================================" -ForegroundColor Cyan
}
function List-Users1 {
Write-Host "`n=== Lista de Usuarios ===" -ForegroundColor Cyan
net user | ForEach-Object { Write-Host $_ }
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
function List-Users {
Write-Host "`n=== Lista de Usuarios ===" -ForegroundColor Cyan
net user | ForEach-Object { Write-Host $_ }
}
function Get-UserInfo {
net user | ForEach-Object { Write-Host $_ }
$username = Read-Host "`nDigite o nome do usuario"
Write-Host "`n=== Informacoes do Usuario: $username ===" -ForegroundColor Cyan
net user $username | ForEach-Object { Write-Host $_ }
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
function Show-Groups {
Write-Host "`n=== Lista de Grupos ===" -ForegroundColor Cyan
net localgroup | ForEach-Object { Write-Host $_ }
$choice = Read-Host "`nDeseja visualizar os membros de algum grupo? (1 para Sim, 0 para Nao)"
if ($choice -eq 1) {
$groupName = Read-Host "Digite o nome do grupo"
Write-Host "`n=== Membros do Grupo: $groupName ===" -ForegroundColor Cyan
net localgroup $groupName | ForEach-Object { Write-Host $_ }
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
}
function Create-User {
$username = Read-Host "`nDigite o nome do novo usuario"
$password = Read-Host "Digite a senha para o novo usuario" -AsSecureString
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
net user $username $password /ADD
Write-Host "Usuario $username criado com sucesso!" -ForegroundColor Cyan
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
function Melhora-Previlegios {
while ($true) {
Clear-Host
Write-Host "`n`n`n`n`n`n"
Write-Host "||========================================================================||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "||=== Menu de Previlegios Win ===||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "||========================================================================||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "|| [1] Adicionar usuario ao grupo de administradores ||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "|| [2] Adicionar usuario a um grupo especifico ||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "|| [3] Adicionar usuario a todos os grupos ||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "|| [4] Adicionar usuario ao grupo de Ass.Global (Ainda nao funciona) ||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "|| [5] Sair ||" -ForegroundColor DarkCyan
Write-Host "|| ||" -ForegroundColor DarkCyan
Write-Host "||========================================================================||`n`n" -ForegroundColor DarkCyan
$opcao = Read-Host "`nEscolha uma opcao (1-5)"
switch ($opcao) {
1 {
List-Users
$username = Read-Host "`n`nDigite o nome do usuario que deseja adicionar ao grupo de administradores"
if (-not (UserExists $username)) {
Write-Host "Erro: O usuario '$username' nao existe." -ForegroundColor Red
continue
}
try {
net localgroup Administradores $username /ADD
Write-Host "Usuario '$username' adicionado ao grupo de administradores com sucesso!" -ForegroundColor Green
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
catch {
Write-Host "Erro ao adicionar o usuario '$username' ao grupo de administradores. Certifique-se de que o PowerShell esta sendo executado como administrador." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
}
2 {
List-Users
Write-Host "=== Lista de Grupos ===" -ForegroundColor Green
net localgroup | ForEach-Object { Write-Host $_ }
$username = Read-Host "Digite o nome do usuario que deseja adicionar a um grupo"
if (-not (UserExists $username)) {
Write-Host "Erro: O usuario '$username' nao existe." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
continue
}
$groupname = Read-Host "`n`nDigite o nome do grupo ao qual deseja adicionar o usuario"
try {
net localgroup $groupname $username /ADD
Write-Host "Usuario '$username' adicionado ao grupo '$groupname' com sucesso!" -ForegroundColor Green
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
}
catch {
Write-Host "Erro ao adicionar o usuario '$username' ao grupo '$groupname'. Certifique-se de que o grupo existe e que o PowerShell esta sendo executado como administrador." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
}
}
3 {
List-Users
$username = Read-Host "`n`nDigite o nome do usuario que deseja adicionar a todos os grupos"
if (-not (UserExists $username)) {
Write-Host "Erro: O usuario '$username' nao existe." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
continue
}
try {
$groups = net localgroup | Where-Object { $_ -match "^\*" } | ForEach-Object { $_.TrimStart('*').Trim() }
foreach ($group in $groups) {
net localgroup $group $username /ADD
Write-Host "Usuario '$username' adicionado ao grupo '$group' com sucesso!" -ForegroundColor Green
}
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
}
catch {
Write-Host "Erro ao adicionar o usuario '$username' a todos os grupos. Certifique-se de que o PowerShell esta sendo executado como administrador." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
}
}
4 {
$nomeUsuario = Read-Host "Digite o nome do usuario que deseja adicionar ao grupo"
$nomeGrupo = "Associações de Grupo Global" ## escrever de maneira correta acentuada caso corromper (ex: Associações) == Associacoes de Grupo Global
try {
Add-ADGroupMember -Identity $nomeGrupo -Members $nomeUsuario
Write-Host "Usuario '$nomeUsuario' adicionado ao grupo '$nomeGrupo' com sucesso!"
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
} catch {
Write-Host "Erro ao adicionar o usuario ao grupo: $_"
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
}
}
5 {
Write-Host "`nVoltando para menu de Usuarios..." -ForegroundColor Red
return
}
default {
Write-Host "`nOpcao invalida. Por favor, escolha uma opcao valida (1-5)." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
}
}
}
}
function UserExists($username) {
$userExists = net user $username 2>&1 | Select-String "O nome da conta poderia nao ser encontrado"
return -not $userExists
}
function Delete-User {
List-Users
$username = Read-Host "Digite o nome do usuario que deseja deletar"
$confirm = Read-Host "Voce realmente deseja excluir o usuario '$username'? (s/n)"
if ($confirm -eq 's') {
net user $username /DELETE
Write-Host "Usuario $username deletado com sucesso!" -ForegroundColor Cyan
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
} else {
Write-Host "Operacao cancelada." -ForegroundColor Yellow
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
}
function Show-LoggedInUsers {
Write-Host "`n=== Usuarios Atualmente Logados ===" -ForegroundColor Cyan
$usuariosLogados = Get-Process -IncludeUserName | Select-Object UserName -Unique
if ($usuariosLogados.Count -eq 0) {
Write-Host "Nenhum usuario logado no momento." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
else {
$usuariosLogados | ForEach-Object {
Write-Host "`nUsuario logado: $($_.UserName)"
}
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Cyan
$null = Read-Host
}
}
while ($true) {
Show-Menu
$opcao = Read-Host "`nEscolha uma opcao (1-8)"
switch ($opcao) {
1 { List-Users1 }
2 { Get-UserInfo }
3 { Show-Groups }
4 { Create-User }
5 { Melhora-Previlegios }
6 { Delete-User }
7 { Show-LoggedInUsers }
8 { return }
default { Write-Host "`nOpcao invalida. Escolha um numero de 1 a 8." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Red
$null = Read-Host
}
}
}
}
function Show-TCPPorts {
Write-Host "`n === Portas TCP Abertas ===" -ForegroundColor Green
$portasTCP = Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, State, OwningProcess
if ($portasTCP.Count -eq 0) {
Write-Host "Nenhuma porta TCP aberta encontrada." -ForegroundColor Red
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
Clear-Host
}
else {
$portasTCP | ForEach-Object {
$process = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
$appName = if ($process) { $process.ProcessName } else { "N/A" }
$_ | Add-Member -MemberType NoteProperty -Name "AppName" -Value $appName -Force
$_.State = "Escutando"
$_
} | Format-Table -Property LocalAddress, LocalPort, State, OwningProcess, AppName -AutoSize
$opcao = Read-Host "`nDeseja encerrar algum processo? (1 - Encerrar, 0 - Voltar ao menu)"
if ($opcao -eq 1) {
$processID = Read-Host "Digite o ID do processo que deseja encerrar"
Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue
if ($?) {
Write-Host "Processo $processID encerrado com sucesso." -ForegroundColor Green
}
else {
Write-Host "Falha ao encerrar o processo $processID." -ForegroundColor Red
}
}
elseif ($opcao -eq 0) {
Write-Host "Voltando ao menu inicial." -ForegroundColor Yellow
}
else {
Write-Host "Opcao invalida. Voltando ao menu inicial." -ForegroundColor Red
}
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
Clear-Host
}
Write-Host "=========================`n"
}
function Show-UDPPorts {
Write-Host "`n === Portas UDP Abertas ===" -ForegroundColor Yellow
$portasUDP = Get-NetUDPEndpoint | Select-Object LocalAddress, LocalPort, OwningProcess
if ($portasUDP.Count -eq 0) {
Write-Host "Nenhuma porta UDP aberta encontrada." -ForegroundColor Red
}
else {
$portasUDP | ForEach-Object {
$process = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
$appName = if ($process) { $process.ProcessName } else { "N/A" }
$_ | Add-Member -MemberType NoteProperty -Name "AppName" -Value $appName -Force
$_ | Add-Member -MemberType NoteProperty -Name "State" -Value "Escutando" -Force
$_
} | Format-Table -Property LocalAddress, LocalPort, State, OwningProcess, AppName -AutoSize
$opcao = Read-Host "`nDeseja encerrar algum processo? (1 - Encerrar, 0 - Voltar ao menu)"
if ($opcao -eq 1) {
$processID = Read-Host "Digite o ID do processo que deseja encerrar"
Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue
if ($?) {
Write-Host "Processo $processID encerrado com sucesso." -ForegroundColor Green
}
else {
Write-Host "Falha ao encerrar o processo $processID." -ForegroundColor Red
}
}
elseif ($opcao -eq 0) {
Write-Host "Voltando ao menu inicial." -ForegroundColor Yellow
}
else {
Write-Host "Opcao invalida. Voltando ao menu inicial." -ForegroundColor Red
}
}
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
Clear-Host
Write-Host "=========================`n"
}
function Show-Apps {
$usuarioAtivo = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$processos = Get-Process | Where-Object { $_.SessionId -eq (Get-Process -Id $PID).SessionId } | Select-Object Id, ProcessName, MainWindowTitle, Path
Write-Host "`n=== Aplicativos em Execucao no Perfil do Usuario Ativo ===" -ForegroundColor Cyan
$processos | Format-Table -AutoSize -Property Id, ProcessName, MainWindowTitle, Path
$opcao = Read-Host "`nDeseja encerrar algum processo? (1 - Encerrar, 0 - Voltar ao menu)"
if ($opcao -eq 1) {
$processID = Read-Host "Digite o ID do processo que deseja encerrar"
Stop-Process -Id $processID -Force -ErrorAction SilentlyContinue
if ($?) {
Write-Host "Processo $processID encerrado com sucesso." -ForegroundColor Green
}
else {
Write-Host "Falha ao encerrar o processo $processID." -ForegroundColor Red
}
}
elseif ($opcao -eq 0) {
Write-Host "Voltando ao menu inicial." -ForegroundColor Yellow
}
else {
Write-Host "Opcao invalida. Voltando ao menu inicial." -ForegroundColor Red
}
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Green
$null = Read-Host
Clear-Host
}
function Wmap {
function Show-Menu {
Clear-Host
Write-Host "`n`n`n`n`n"
Write-Host "==================================================" -ForegroundColor Yellow
Write-Host "|| === WMap === ||" -ForegroundColor Yellow
Write-Host "==================================================" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| 1. Pingar IP ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| 2. Criar Lista de IP ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| 3. Descobrir Maquinas Ativas de um IP ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| 4. Pingar Porta Especifica ( info ) ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| 5. Pingar todas as Portas de um IP ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| 6. Pingar 100 portas mais usadas ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| 0. Menu Principal ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "|| ||" -ForegroundColor Yellow
Write-Host "==================================================`n`n" -ForegroundColor Yellow
}
function Pingar-Ip {
Write-Host "`n"
$ip = Read-Host "Digite o IP"
Write-Host "`nEfetuando ping no host: $ip"
$pingResult = Test-Connection -ComputerName $ip -Count 3 -Quiet
if ($pingResult) {
Write-Host "`n - - RED TEAM - - " -ForegroundColor Red
ping -n 2 $ip | Select-String "bytes=32"
Write-Host "`n`nO host: $ip :ONLINE" -ForegroundColor Green
} else {
ping -n 5 $ip | Select-String "bytes=32"
Write-Host "`n`nFalha ao pingar o host: $ip :OFFLINE" -ForegroundColor Yellow
}
}
function Criar-Lista {
Write-Host "`n"
$baseIP = Read-Host "Digite a parte inicial do IP (Ex: 192.168.10.)"
if (-not $baseIP.EndsWith(".")) {
Write-Host "Formato invalido. Certifique-se de incluir o ponto final (Ex: 192.168.10.)" -ForegroundColor Red
return
}
Write-Host "`nGerando lista de IPs..." -ForegroundColor Yellow
foreach ($i in 1..254) {
$ip = "$baseIP$i"
Write-Host $ip
}
Write-Host "`nLista de IPs gerada com sucesso!" -ForegroundColor Green
}
function Pingar-Ip-Rede {
Write-Host "`n( esse comando vai pingar todos os enderecos de 1 - 254 pode levar ate 20 minutos )"
$baseIP = Read-Host "Digite a parte inicial do IP (Ex: 192.168.10.)"
if (-not $baseIP.EndsWith(".")) {
Write-Host "Formato invalido. Certifique-se de incluir o ponto final (Ex: 192.168.10.)" -ForegroundColor Red
return
}
Write-Host "`nPingando enderecos de 1 a 254 do IP $baseIP ..." -ForegroundColor Yellow
# Loop para pingar cada IP na rede
foreach ($ip in 1..254) {
$fullIP = "$baseIP$ip" # Concatena a base do IP com o numero atual
Write-Host "`nPingando: $fullIP " -ForegroundColor Yellow
$result = ping -n 1 $fullIP | Select-String "bytes=32"
# Exibe o resultado do ping
if ($result) {
Write-Host "$fullIP respondeu ao ping." -ForegroundColor Green
} else {
Write-Host "$fullIP nao respondeu ao ping." -ForegroundColor Red
}
}
Write-Host "`nPing concluido!" -ForegroundColor Yellow
}
function Pingar-Porta-IP {
Write-Host "`n"
$ip = Read-Host "Digite o IP (alvo)"
$porta = Read-Host "Digite a porta"
if (-not $ip -or -not $porta) {
Write-Host "Dados Inseridos corretamente..." -ForegroundColor Red
return
}
if (-not ($porta -match '^\d+$') -or [int]$porta -lt 1 -or [int]$porta -gt 65535) {
Write-Host "`nPorta invalida. A porta deve ser um numero entre 1 e 65535." -ForegroundColor Red
return
}
Write-Host "`nVerificando a porta $porta no IP $ip..." -ForegroundColor Yellow
$resultado = Test-NetConnection -ComputerName $ip -Port $porta -WarningAction SilentlyContinue
Write-Host "`n=== Detalhes da Conexao ===" -ForegroundColor Cyan
Write-Host "ComputerName: $($resultado.ComputerName)" -ForegroundColor Green
Write-Host "RemoteAddress: $($resultado.RemoteAddress)" -ForegroundColor Green
Write-Host "RemotePort: $($resultado.RemotePort)" -ForegroundColor Green
Write-Host "InterfaceAlias: $($resultado.InterfaceAlias)" -ForegroundColor Green
Write-Host "SourceAddress: $($resultado.SourceAddress)" -ForegroundColor Green
Write-Host "PingReplyDetails (RTT): $($resultado.PingReplyDetails.RoundtripTime) ms" -ForegroundColor Green
Write-Host "TcpTestSucceeded: $($resultado.TcpTestSucceeded)" -ForegroundColor Green
if ($resultado.TcpTestSucceeded) {
Write-Host "`nPorta $porta esta aberta no IP $ip." -ForegroundColor Green
} else {
Write-Host "`nPorta $porta esta fechada no IP $ip." -ForegroundColor Red
}
}
function Validar-IP {
param (
[string]$ip
)
$regex = '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
return ($ip -match $regex)
}
function Pingar-Todas-Portas-Ip {
Write-Host "`n"
Write-Host "Obs:(Esta acao pode levar alguns minutos:65535 portas)"
do {
$ip = Read-Host "Digite o IP (alvo)"
if (-not (Validar-IP $ip)) {
Write-Host "Endereco IP invalido. Tente novamente." -ForegroundColor Yellow
return
}
} while (-not (Validar-IP $ip))
Write-Host "`n- Scan Iniciado -" -ForegroundColor Yellow
$totalPortas = 65535
$portasAbertas = @()
for ($porta = 1; $porta -le $totalPortas; $porta++) {
if (Test-NetConnection $ip -Port $porta -WarningAction SilentlyContinue -InformationLevel Quiet) {
Write-Host "Porta $porta Aberta" -ForegroundColor Green
$portasAbertas += $porta
} else {
# Write-Host "Porta $porta Fechada" -ForegroundColor Red
Continue
}
}
Write-Host "Portas abertas: $($portasAbertas -join ', ')"
}
function Pingar-Portas-Comuns-Ip {
Write-Host "`n"
do {
Write-Host "Obs:(Esta acao pode levar alguns minutos:100 portas)"
$ip = Read-Host "Digite o IP (alvo)"
if (-not (Validar-IP $ip)) {
Write-Host "Endereco IP invlido. Tente novamente." -ForegroundColor Yellow
return
}
} while (-not (Validar-IP $ip))
Write-Host "`nIniciando Scan nas 100 portas mais comuns..."
$portasComuns = @(
20, 21, 22, 23, 25, 53, 67, 68, 69, 80, 110, 123, 135, 137, 138, 139, 143, 161, 162, 389, 443,
445, 465, 500, 512, 513, 514, 587, 636, 873, 993, 995, 1025, 1026, 1027, 1028, 1029, 1080, 1194,
1433, 1434, 1701, 1723, 1812, 1813, 1900, 2049, 2181, 2375, 2376, 2483, 2484, 3306, 3389, 3478,
4500, 5000, 5060, 5061, 5353, 5355, 5432, 5555, 5900, 5985, 5986, 6000, 6379, 6667, 7000, 8080,
8081, 8192, 8443, 8888, 9000, 9090, 9100, 9200, 9300, 9418, 9999, 10000, 11211, 25565, 27017,
27018, 27019, 28015, 28017, 31337, 32768, 37777, 49152, 49153, 49154, 49155, 49156, 49157,
49158, 49159, 49160, 49161, 49162, 49163, 49164, 49165
)
$portasAbertas = @()
foreach ($porta in $portasComuns) {
if (Test-NetConnection $ip -Port $porta -WarningAction SilentlyContinue -InformationLevel Quiet) {
Write-Host "Porta $porta Aberta" -ForegroundColor Green
$portasAbertas += $porta
} else {
Write-Host "Porta $porta Fechada" -ForegroundColor Red
}
}
Write-Host "Portas abertas: $($portasAbertas -join ', ')"
}
do {
Show-Menu
$choice = Read-Host "Escolha um numero de ( 1 - 6 )"
switch ($choice) {
1 { Pingar-Ip }
2 { Criar-Lista }
3 { Pingar-Ip-Rede }
4 { Pingar-Porta-IP }
5 { Pingar-Todas-Portas-Ip }
6 { Pingar-Portas-Comuns-Ip }
0 { Write-Host "Voltando ao menu principal..." -ForegroundColor Yellow; break }
default { Write-Host "`nOpcao invalida. Escola um numero entre 1 a 6." -ForegroundColor Yellow }
}
if ($choice -ne 0) {
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Yellow
$null = Read-Host
}
} while ($choice -ne 0)
}
function Busca-Por-DNS {
$headers = @{
"User-Agent" = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36"
}
# === Funcoes ===
function ScanHeaders {
param ([string]$url)
try {
Write-Host "`n Escaneando Headers..." -ForegroundColor Cyan
$response = Invoke-WebRequest -Uri $url -Method Head -Headers $headers -ErrorAction Stop
Write-Host "`n O servidor roda:" -ForegroundColor Green
$response.Headers.Server
} catch {
Write-Host "`nErro ao buscar headers: $_" -ForegroundColor Red
}
}
function ScanOptions {
param ([string]$url)
try {
Write-Host "`n Verificando metodos HTTP suportados..." -ForegroundColor Cyan
$response = Invoke-WebRequest -Uri $url -Method Options -Headers $headers -ErrorAction Stop
Write-Host "`n Metodos permitidos pelo servidor:" -ForegroundColor Green
$response.Headers.Allow
} catch {
Write-Host "`nErro ao buscar metodos OPTIONS: $_" -ForegroundColor Red
}
}
function ScanLinks {
param ([string]$url)
try {
Write-Host "`n Procurando links na pagina..." -ForegroundColor Cyan
$response = Invoke-WebRequest -Uri $url -Headers $headers -ErrorAction Stop
Write-Host "`n Links encontrados:" -ForegroundColor Green
$response.Links.Href | Select-String http
} catch {
Write-Host "`nErro ao buscar links: $_" -ForegroundColor Red
}
}
function ScanHTML {
param ([string]$url)
try {
Write-Host "`n Obtendo codigo-fonte do HTML..." -ForegroundColor Cyan
$response = Invoke-WebRequest -Uri $url -Headers $headers -ErrorAction Stop
Write-Host "`n Codigo HTML recebido:" -ForegroundColor Green
Write-Host $response.Content.Substring(0, 500) # Exibe os primeiros 500 caracteres
} catch {
Write-Host "`nErro ao obter o HTML: $_" -ForegroundColor Red
}
}
function ScanTech {
param ([string]$url)
try {
Write-Host "`n Detectando tecnologias utilizadas..." -ForegroundColor Cyan
$response = Invoke-WebRequest -Uri $url -Headers $headers -ErrorAction Stop
if ($response.Headers["x-powered-by"]) {
Write-Host "`n Tecnologia detectada:" -ForegroundColor Green
$response.Headers["x-powered-by"]
} else {
Write-Host "Nenhuma tecnologia detectada nos headers."
}
} catch {
Write-Host "`nErro ao buscar tecnologias: $_" -ForegroundColor Red
}
}
function ScanStatusCode {
param ([string]$url)
try {
Write-Host "`n Obtendo codigo de status HTTP..." -ForegroundColor Cyan
$response = Invoke-WebRequest -Uri $url -Headers $headers -ErrorAction Stop
Write-Host "`n Status Code:" -ForegroundColor Green
$response.StatusCode
} catch {
Write-Host "`nErro ao obter Status Code: $_" -ForegroundColor Red
}
}
function ScanTitle {
param ([string]$url)
try {
Write-Host "`n Obtendo titulo da pagina..." -ForegroundColor Cyan
$response = Invoke-WebRequest -Uri $url -Headers $headers -ErrorAction Stop
if ($response.ParsedHtml.title) {
Write-Host "`n Titulo da pagina:" -ForegroundColor Green
$response.ParsedHtml.title
} else {
Write-Host "`nNenhum titulo encontrado."
}
} catch {
Write-Host "`nErro ao obter titulo da pagina: $_" -ForegroundColor Red
}
}
function ScanRobotsTxt {
param ([string]$url)
try {
Write-Host "`n Procurando robots.txt..." -ForegroundColor Cyan
$robotsUrl = "$url/robots.txt"
$response = Invoke-WebRequest -Uri $robotsUrl -Headers $headers -ErrorAction Stop
Write-Host "`n Conteudo do robots.txt:" -ForegroundColor Green
Write-Host $response.Content
} catch {
Write-Host "`nErro ao buscar robots.txt: $_" -ForegroundColor Red
}
}
function ScanSitemap {
param ([string]$url)
try {
Write-Host "`n Verificando sitemap.xml..." -ForegroundColor Cyan
$sitemapUrl = "$url/sitemap.xml"
$response = Invoke-WebRequest -Uri $sitemapUrl -Headers $headers -ErrorAction Stop
Write-Host "`n Sitemap encontrado:" -ForegroundColor Green
Write-Host $response.Content.Substring(0, 500)
} catch {
Write-Host "`nErro ao buscar sitemap.xml: $_" -ForegroundColor Red
}
}
function ScanPorts {
param ([string]$host)
$ports = @(21, 22, 25, 53, 80, 110, 143, 443, 3306, 8080)
Write-Host "`n Escaneando portas comuns..." -ForegroundColor Cyan
foreach ($port in $ports) {
try {
$tcp = New-Object System.Net.Sockets.TcpClient
$tcp.Connect($host, $port)
Write-Host "Porta $port aberta!" -ForegroundColor Green
$tcp.Close()
} catch {
Write-Host "Porta $port fechada."
}
}
}
function RunAllScans {
param ([string]$url)
Write-Host "`n=== Iniciando todas as verificacoes para a URL: $url ===`n" -ForegroundColor Magenta
Write-Host "`n=== 1. Captura Headers do Servidor ===" -ForegroundColor Magenta
ScanHeaders -url $url
Write-Host "`n=== 2. Descobre os Metodos HTTP Permitidos ===" -ForegroundColor Magenta
ScanOptions -url $url
Write-Host "`n=== 3. Lista os Links Encontrados no HTML ===" -ForegroundColor Magenta
ScanLinks -url $url
Write-Host "`n=== 4. Obtem Codigo-Fonte do HTML ===" -ForegroundColor Magenta
ScanHTML -url $url
Write-Host "`n=== 5. Detecta Tecnologias Utilizadas ===" -ForegroundColor Magenta
ScanTech -url $url
Write-Host "`n=== 6. Obtem Codigo de Status HTTP ===" -ForegroundColor Magenta
ScanStatusCode -url $url
Write-Host "`n=== 7. Obtem o <title> da Pagina ===" -ForegroundColor Magenta
ScanTitle -url $url
Write-Host "`n=== 8. Verifica o arquivo robots.txt ===" -ForegroundColor Magenta
ScanRobotsTxt -url $url
Write-Host "`n=== 9. Verifica se o site possui um Sitemap ===" -ForegroundColor Magenta
ScanSitemap -url $url
Write-Host "`n=== Todas as verificacoes foram concluidas! ===`n" -ForegroundColor Magenta
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
while ($true) {
Clear-Host
Write-Host "`n`n`n`n`n`n+==================================================+" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| === Menu de busca por DNS === ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "+==================================================+" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 1. Captura Headers do Servidor ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 2. Descobre os Metodos HTTP Permitidos ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 3. Lista os Links Encontrados no HTML ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 4. Obtem Codigo-Fonte do HTML ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 5. Detecta Tecnologias Utilizadas ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 6. Obtem Codigo de Status HTTP ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 7. Obtem o <title> da Pagina ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 8. Verifica o arquivo robots.txt ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 9. Verifica se o site possui um Sitemap ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 10. Faz um Scan Rapido das Portas Comuns ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 11. Rodar todas opcoes (1 a 9) ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "|| 12. Voltar para o Menu Principal ||" -ForegroundColor Magenta
Write-Host "|| ||" -ForegroundColor Magenta
Write-Host "+==================================================+" -ForegroundColor Magenta
Write-Host "`n`n"
$opcao = Read-Host "`nEscolha uma opcao (1-12)"
switch ($opcao) {
1 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanHeaders -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
2 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanOptions -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
3 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanLinks -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
4 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanHTML -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
5 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanTech -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
6 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanStatusCode -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
7 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanTitle -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
8 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanRobotsTxt -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
9 {
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
ScanSitemap -url $url
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
10 {
$host = Read-Host "`nDigite o host ou IP (ex: exemplo.com ou 192.168.1.1)"
ScanPorts -host $host
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
11{
$url = Read-Host "`nDigite a URL do site (ex: https://exemplo.com)"
RunAllScans -url $url
}
12 {
Write-Host "`nSaindo..." -ForegroundColor Magenta
return
}
default {
Write-Host "`nOpcao invalida. Escolha um numero entre 1 a 12." -ForegroundColor Magenta
Write-Host "`nPressione Enter para continuar..." -ForegroundColor Magenta
$null = Read-Host
}
}
}
}
while ($true) {
Clear-Host
Write-Host "`n`n`n`n`n`n+====================================================================+" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| === Menu Principal === ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "+====================================================================+" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 1. Mostrar informacoes do computador ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 2. Informacoes avancadas de Usuarios ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 3. Listar portas TCP abertas ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 4. Listar portas UDP abertas ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 5. Listar aplicativos em uso ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 6. WMap ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 7. DNS Requests ||" -ForegroundColor Green
Write-Host "|| ||" -ForegroundColor Green
Write-Host "|| 0. Sair ||" -ForegroundColor Green