@@ -140,41 +140,41 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
140
140
elseif ($ Command === 'url_sig ' ) {
141
141
echo "\n" ;
142
142
$ Clean = $ this ->Scanner ->normalise (substr ($ Clean , strlen ($ Command ) + 1 ));
143
- $ URL = ['avoidme ' => '' , 'forthis ' => '' ];
143
+ $ URL = ['AvoidMe ' => '' , 'ForThis ' => '' ];
144
144
if (
145
145
!preg_match_all ('/(data|file|https?|ftps?|sftp|ss[hl])\:\/\/(www\d{0,3}\.)?([\da-z.-]{1,512})/i ' , $ Clean , $ URL ['domain ' ]) ||
146
146
!preg_match_all ('/(data|file|https?|ftps?|sftp|ss[hl])\:\/\/(www\d{0,3}\.)?([\!\#\$\&-;\=\?\@-\[\]_a-z~]{1,4000})/i ' , $ Clean , $ URL ['url ' ])
147
147
) {
148
148
echo $ this ->Loader ->L10N ->getString ('invalid_url ' ) . "\n" ;
149
- } else {
150
- echo 'DOMAIN: ' . md5 ($ URL ['domain ' ][3 ][0 ]) . ': ' . strlen ($ URL ['domain ' ][3 ][0 ]) . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
151
- $ URL ['forthis ' ] = md5 ($ URL ['url ' ][3 ][0 ]) . ': ' . strlen ($ URL ['url ' ][3 ][0 ]);
152
- $ URL ['avoidme ' ] .= ', ' . $ URL ['forthis ' ] . ', ' ;
153
- echo 'URL: ' . $ URL ['forthis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
154
- if (preg_match ('/[^\da-z.-]$/i ' , $ URL ['url ' ][3 ][0 ])) {
155
- $ URL ['x ' ] = preg_replace ('/[^\da-z.-]+$/i ' , '' , $ URL ['url ' ][3 ][0 ]);
156
- $ URL ['forthis ' ] = md5 ($ URL ['x ' ]) . ': ' . strlen ($ URL ['x ' ]);
157
- if (strpos ($ URL ['avoidme ' ], $ URL ['forthis ' ]) === false ) {
158
- $ URL ['avoidme ' ] .= ', ' . $ URL ['forthis ' ] . ', ' ;
159
- echo 'URL: ' . $ URL ['forthis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
160
- }
149
+ continue ;
150
+ }
151
+ echo 'DOMAIN: ' . hash ('md5 ' , $ URL ['domain ' ][3 ][0 ]) . ': ' . strlen ($ URL ['domain ' ][3 ][0 ]) . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
152
+ $ URL ['ForThis ' ] = hash ('md5 ' , $ URL ['url ' ][3 ][0 ]) . ': ' . strlen ($ URL ['url ' ][3 ][0 ]);
153
+ $ URL ['AvoidMe ' ] .= ', ' . $ URL ['ForThis ' ] . ', ' ;
154
+ echo 'URL: ' . $ URL ['ForThis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
155
+ if (preg_match ('/[^\da-z.-]$/i ' , $ URL ['url ' ][3 ][0 ])) {
156
+ $ URL ['x ' ] = preg_replace ('/[^\da-z.-]+$/i ' , '' , $ URL ['url ' ][3 ][0 ]);
157
+ $ URL ['ForThis ' ] = hash ('md5 ' , $ URL ['x ' ]) . ': ' . strlen ($ URL ['x ' ]);
158
+ if (strpos ($ URL ['AvoidMe ' ], $ URL ['ForThis ' ]) === false ) {
159
+ $ URL ['AvoidMe ' ] .= ', ' . $ URL ['ForThis ' ] . ', ' ;
160
+ echo 'URL: ' . $ URL ['ForThis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
161
+ }
162
+ }
163
+ if (strpos ($ URL ['url ' ][3 ][0 ], '? ' ) !== false ) {
164
+ $ URL ['x ' ] = $ this ->Loader ->substrBeforeFirst ($ URL ['url ' ][3 ][0 ], '? ' );
165
+ $ URL ['ForThis ' ] = hash ('md5 ' , $ URL ['x ' ]) . ': ' . strlen ($ URL ['x ' ]);
166
+ if (strpos ($ URL ['AvoidMe ' ], $ URL ['ForThis ' ]) === false ) {
167
+ $ URL ['AvoidMe ' ] .= ', ' . $ URL ['ForThis ' ] . ', ' ;
168
+ echo 'URL: ' . $ URL ['ForThis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
161
169
}
162
- if (strpos ($ URL ['url ' ][3 ][0 ], '? ' ) !== false ) {
163
- $ URL ['x ' ] = $ this ->Loader ->substrBeforeFirst ($ URL ['url ' ][3 ][0 ], '? ' );
164
- $ URL ['forthis ' ] = md5 ($ URL ['x ' ]) . ': ' . strlen ($ URL ['x ' ]);
165
- if (strpos ($ URL ['avoidme ' ], $ URL ['forthis ' ]) === false ) {
166
- $ URL ['avoidme ' ] .= ', ' . $ URL ['forthis ' ] . ', ' ;
167
- echo 'URL: ' . $ URL ['forthis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
168
- }
169
- $ URL ['x ' ] = $ this ->Loader ->substrAfterFirst ($ URL ['url ' ][3 ][0 ], '? ' );
170
- $ URL ['forthis ' ] = md5 ($ URL ['x ' ]) . ': ' . strlen ($ URL ['x ' ]);
171
- if (
172
- strpos ($ URL ['avoidme ' ], $ URL ['forthis ' ]) === false &&
173
- $ URL ['forthis ' ] != 'd41d8cd98f00b204e9800998ecf8427e:0 '
174
- ) {
175
- $ URL ['avoidme ' ] .= ', ' . $ URL ['forthis ' ] . ', ' ;
176
- echo 'QUERY: ' . $ URL ['forthis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
177
- }
170
+ $ URL ['x ' ] = $ this ->Loader ->substrAfterFirst ($ URL ['url ' ][3 ][0 ], '? ' );
171
+ $ URL ['ForThis ' ] = hash ('md5 ' , $ URL ['x ' ]) . ': ' . strlen ($ URL ['x ' ]);
172
+ if (
173
+ strpos ($ URL ['AvoidMe ' ], $ URL ['ForThis ' ]) === false &&
174
+ $ URL ['ForThis ' ] !== 'd41d8cd98f00b204e9800998ecf8427e:0 '
175
+ ) {
176
+ $ URL ['AvoidMe ' ] .= ', ' . $ URL ['ForThis ' ] . ', ' ;
177
+ echo 'QUERY: ' . $ URL ['ForThis ' ] . ': ' . $ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' ) . "\n" ;
178
178
}
179
179
}
180
180
unset($ URL );
@@ -299,58 +299,57 @@ private function peMeta(string $File): string
299
299
if (substr ($ Data , 0 , 2 ) !== 'MZ ' ) {
300
300
return $ this ->Loader ->L10N ->getString ('cli_pe1 ' ) . "\n" ;
301
301
}
302
- $ PEArr = [ ' Len ' => strlen ($ Data )] ;
303
- $ PEArr [ ' Offset ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , 60 , 4 ));
304
- $ PEArr [ ' Offset ' ] = $ PEArr [ ' Offset ' ] [1 ];
302
+ $ PELength = strlen ($ Data );
303
+ $ Offset = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , 60 , 4 ));
304
+ $ Offset = $ Offset [1 ];
305
305
while (true ) {
306
- $ PEArr [ ' DoScan ' ] = true ;
307
- if ($ PEArr [ ' Offset ' ] < 1 || $ PEArr [ ' Offset ' ] > 16384 || $ PEArr [ ' Offset ' ] > $ PEArr [ ' Len ' ] ) {
308
- $ PEArr [ ' DoScan ' ] = false ;
306
+ $ Valid = true ;
307
+ if ($ Offset < 1 || $ Offset > 16384 || $ Offset > $ PELength ) {
308
+ $ Valid = false ;
309
309
break ;
310
310
}
311
- $ PEArr [ ' Magic ' ] = substr ($ Data , $ PEArr [ ' Offset ' ] , 2 );
312
- if ($ PEArr [ ' Magic ' ] !== 'PE ' ) {
313
- $ PEArr [ ' DoScan ' ] = false ;
311
+ $ Magic = substr ($ Data , $ Offset , 2 );
312
+ if ($ Magic !== 'PE ' ) {
313
+ $ Valid = false ;
314
314
break ;
315
315
}
316
- $ PEArr [ ' Proc ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , $ PEArr [ ' Offset ' ] + 4 , 2 ));
317
- $ PEArr [ ' Proc ' ] = $ PEArr [ ' Proc ' ] [1 ];
318
- if ($ PEArr [ ' Proc ' ] != 0x14c && $ PEArr [ ' Proc ' ] != 0x8664 ) {
319
- $ PEArr [ ' DoScan ' ] = false ;
316
+ $ Proc = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , $ Offset + 4 , 2 ));
317
+ $ Proc = $ Proc [1 ];
318
+ if ($ Proc != 0x14c && $ Proc != 0x8664 ) {
319
+ $ Valid = false ;
320
320
break ;
321
321
}
322
- $ PEArr [ ' NumOfSections ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , $ PEArr [ ' Offset ' ] + 6 , 2 ));
323
- $ PEArr [ ' NumOfSections ' ] = $ PEArr [ ' NumOfSections ' ] [1 ];
324
- if ($ PEArr [ ' NumOfSections ' ] < 1 || $ PEArr [ ' NumOfSections ' ] > 40 ) {
325
- $ PEArr [ ' DoScan ' ] = false ;
322
+ $ NumberOfSections = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , $ Offset + 6 , 2 ));
323
+ $ NumberOfSections = $ NumberOfSections [1 ];
324
+ if ($ NumberOfSections < 1 || $ NumberOfSections > 40 ) {
325
+ $ Valid = false ;
326
326
}
327
327
break ;
328
328
}
329
- if (!$ PEArr [ ' DoScan ' ] ) {
329
+ if (!$ Valid ) {
330
330
return $ this ->Loader ->L10N ->getString ('cli_pe1 ' ) . "\n" ;
331
331
}
332
- $ PEArr [ ' OptHdrSize ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , $ PEArr [ ' Offset ' ] + 20 , 2 ));
333
- $ PEArr [ ' OptHdrSize ' ] = $ PEArr [ ' OptHdrSize ' ] [1 ];
332
+ $ OptHdrSize = $ this ->Loader ->unpackSafe ('S ' , substr ($ Data , $ Offset + 20 , 2 ));
333
+ $ OptHdrSize = $ OptHdrSize [1 ];
334
334
$ Returnable .= $ this ->Loader ->L10N ->getString ('cli_pe2 ' ) . "\n" ;
335
- for ($ PEArr [ ' k ' ] = 0 ; $ PEArr [ ' k ' ] < $ PEArr [ ' NumOfSections ' ] ; $ PEArr [ ' k ' ] ++) {
336
- $ PEArr [ ' SectionHead ' ] = substr ($ Data , $ PEArr [ ' Offset ' ] + 24 + $ PEArr [ ' OptHdrSize ' ] + ($ PEArr [ ' k ' ] * 40 ), $ PEArr [ ' NumOfSections ' ] * 40 );
337
- $ PEArr [ ' SectionName ' ] = str_ireplace ("\x00" , '' , substr ($ PEArr [ ' SectionHead ' ] , 0 , 8 ));
338
- $ PEArr [ ' VirtualSize ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ PEArr [ ' SectionHead ' ] , 8 , 4 ));
339
- $ PEArr [ ' VirtualSize ' ] = $ PEArr [ ' VirtualSize ' ] [1 ];
340
- $ PEArr [ ' VirtualAddress ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ PEArr [ ' SectionHead ' ] , 12 , 4 ));
341
- $ PEArr [ ' VirtualAddress ' ] = $ PEArr [ ' VirtualAddress ' ] [1 ];
342
- $ PEArr [ ' SizeOfRawData ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ PEArr [ ' SectionHead ' ] , 16 , 4 ));
343
- $ PEArr [ ' SizeOfRawData ' ] = $ PEArr [ ' SizeOfRawData ' ] [1 ];
344
- $ PEArr [ ' PointerToRawData ' ] = $ this ->Loader ->unpackSafe ('S ' , substr ($ PEArr [ ' SectionHead ' ] , 20 , 4 ));
345
- $ PEArr [ ' PointerToRawData ' ] = $ PEArr [ ' PointerToRawData ' ] [1 ];
346
- $ PEArr [ ' SectionData ' ] = substr ($ Data , $ PEArr [ ' PointerToRawData ' ] , $ PEArr [ ' SizeOfRawData ' ] );
347
- $ PEArr [ ' SHA256 ' ] = hash ('sha256 ' , $ PEArr [ ' SectionData ' ] );
348
- $ Returnable .= $ PEArr [ ' SizeOfRawData ' ] . ': ' . $ PEArr [ ' SHA256 ' ] . ': ' . $ PEArr [ ' SectionName ' ] . "\n" ;
335
+ for ($ PECaret = 0 ; $ PECaret < $ NumberOfSections ; $ PECaret ++) {
336
+ $ SectionHead = substr ($ Data , $ Offset + 24 + $ OptHdrSize + ($ PECaret * 40 ), $ NumberOfSections * 40 );
337
+ $ SectionName = str_ireplace ("\x00" , '' , substr ($ SectionHead , 0 , 8 ));
338
+ $ VirtualSize = $ this ->Loader ->unpackSafe ('S ' , substr ($ SectionHead , 8 , 4 ));
339
+ $ VirtualSize = $ VirtualSize [1 ];
340
+ $ VirtualAddress = $ this ->Loader ->unpackSafe ('S ' , substr ($ SectionHead , 12 , 4 ));
341
+ $ VirtualAddress = $ VirtualAddress [1 ];
342
+ $ SizeOfRawData = $ this ->Loader ->unpackSafe ('S ' , substr ($ SectionHead , 16 , 4 ));
343
+ $ SizeOfRawData = $ SizeOfRawData [1 ];
344
+ $ PointerToRawData = $ this ->Loader ->unpackSafe ('S ' , substr ($ SectionHead , 20 , 4 ));
345
+ $ PointerToRawData = $ PointerToRawData [1 ];
346
+ $ SectionData = substr ($ Data , $ PointerToRawData , $ SizeOfRawData );
347
+ $ SHA256 = hash ('sha256 ' , $ SectionData );
348
+ $ Returnable .= $ SizeOfRawData . ': ' . $ SHA256 . ': ' . $ SectionName . "\n" ;
349
349
}
350
350
$ Returnable .= "\n" ;
351
351
if (strpos ($ Data , "V \x00a \x00r \x00F \x00i \x00l \x00e \x00I \x00n \x00f \x00o \x00\x00\x00\x00\x00\x24" ) !== false ) {
352
- $ PEArr ['Parts ' ] = $ this ->Loader ->substrAfterLast ($ Data , "V \x00a \x00r \x00F \x00i \x00l \x00e \x00I \x00n \x00f \x00o \x00\x00\x00\x00\x00\x24" );
353
- $ PEArr ['FINFO ' ] = [];
352
+ $ PEParts = $ this ->Loader ->substrAfterLast ($ Data , "V \x00a \x00r \x00F \x00i \x00l \x00e \x00I \x00n \x00f \x00o \x00\x00\x00\x00\x00\x24" );
354
353
foreach ([
355
354
["F \x00i \x00l \x00e \x00D \x00e \x00s \x00c \x00r \x00i \x00p \x00t \x00i \x00o \x00n \x00\x00\x00" , 'PEFileDescription ' ],
356
355
["F \x00i \x00l \x00e \x00V \x00e \x00r \x00s \x00i \x00o \x00n \x00\x00\x00" , 'PEFileVersion ' ],
@@ -360,17 +359,17 @@ private function peMeta(string $File): string
360
359
["O \x00r \x00i \x00g \x00i \x00n \x00a \x00l \x00F \x00i \x00l \x00e \x00n \x00a \x00m \x00e \x00\x00\x00" , 'PEOriginalFilename ' ],
361
360
["C \x00o \x00m \x00p \x00a \x00n \x00y \x00N \x00a \x00m \x00e \x00\x00\x00" , 'PECompanyName ' ],
362
361
] as $ PEVars ) {
363
- if (strpos ($ PEArr [ ' Parts ' ] , $ PEVars [0 ]) !== false && (
364
- $ PEArr [ ' ThisData ' ] = trim (str_ireplace ("\x00" , '' , $ this ->Loader ->substrBeforeFirst (
365
- $ this ->Loader ->substrAfterLast ($ PEArr [ ' Parts ' ] , $ PEVars [0 ]),
362
+ if (strpos ($ PEParts , $ PEVars [0 ]) !== false && (
363
+ $ ThisPEData = trim (str_ireplace ("\x00" , '' , $ this ->Loader ->substrBeforeFirst (
364
+ $ this ->Loader ->substrAfterLast ($ PEParts , $ PEVars [0 ]),
366
365
"\x00\x00\x00"
367
366
)))
368
367
)) {
369
368
$ Returnable .= sprintf (
370
369
"\$%s:%s:%d:%s \n" ,
371
370
$ PEVars [1 ],
372
- hash ('sha256 ' , $ PEArr [ ' ThisData ' ] ),
373
- strlen ($ PEArr [ ' ThisData ' ] ),
371
+ hash ('sha256 ' , $ ThisPEData ),
372
+ strlen ($ ThisPEData ),
374
373
$ this ->Loader ->L10N ->getString ('cli_signature_placeholder ' )
375
374
);
376
375
}
0 commit comments