@@ -407,21 +407,25 @@ export function isPotentiallyDangerousCommand(command: string): boolean {
407407 / \b s h r e d \b / , // secure file deletion
408408 / \b : ( ) { :| & } ; : \b / , // fork bomb
409409 / \b c h m o d \s + - R \s + ( 7 7 7 | 7 7 5 ) \b / , // overly permissive
410+ / \b c h m o d \s + 7 7 7 \b / , // any chmod 777
410411 / \b c h o w n \s + - R \s + r o o t \b / , // ownership takeover
411412 / \b c h o w n \s + - R \s + \S + \s + \/ \b / , // chown -R on the root directory
413+ / \b c h o w n \s + - R \b .* \/ h o m e \/ \S + / , // recursive home ownership change
412414 / \b m o u n t \s + .* \/ d e v \/ / , // mounting raw devices
413415 / \b u m o u n t \s + .* \/ d e v \/ / , // unmount devices
414416 / \b > \s * ( \/ e t c | \/ v a r | \/ u s r ) \/ / , // destructive redirection to system directories
415417 / \b w g e t \s + .* \s + \| \s * ( b a s h | s h | z s h | k s h ) \b / , // pipe remote script
416418 / \b c u r l \s + .* \s + \| \s * ( b a s h | s h | z s h | k s h ) \b / , // pipe remote script
417419 / \b s u d o \s + .* ( r m | d d | m k f s | s h u t d o w n | r e b o o t | h a l t | p o w e r o f f ) \b / , // sudo with critical commands
420+ / \b s u d o \s + - l / , // sudo list (checking for permissions)
418421 / \b s h u t d o w n \b / , // shutdown system
419422 / \b r e b o o t \b / , // reboot system
420423 / \b h a l t \b / , // halt system
421424 / \b p o w e r o f f \b / , // power off
422425 / \b f i n d \s + .* - d e l e t e \b / , // find with -delete action
423426 / \b k i l l a l l \b / , // kill all processes
424427 / \b k i l l \s + - 9 / , // forcefully kill processes
428+ / \b k i l l \s + - C O N T \b / , // resuming stopped processes forcefully
425429 / \b n e t c a t \b | \b n c \b / , // netcat tool
426430 / \b d p k g \s + - - p u r g e \b / , // dpkg with purge flag
427431 / \b a p t - g e t \s + p u r g e \b / , // apt with purge
@@ -441,9 +445,12 @@ export function isPotentiallyDangerousCommand(command: string): boolean {
441445 / \b n m a p \b / , // network scanning tool
442446 / \b w i r e s h a r k \b / , // packet sniffer
443447 / \b i w c o n f i g \b | \b i f c o n f i g \b / , // network configuration commands
448+ / \b i p \s + r o u t e \s + d e l / , // delete network route
444449 / \b s y s t e m c t l \s + s t o p \b / , // stopping system services
445450 / \b s y s t e m c t l \s + d i s a b l e \b / , // disabling system services
446451 / \b s y s t e m c t l \s + r e b o o t \b / , // reboot using systemctl
452+ / \b s e r v i c e \s + .* s t o p \b / , // stop services
453+ / \b s e r v i c e \s + .* r e s t a r t \b / , // restart services
447454 / \b r s y n c \s + .* - - d e l e t e - a f t e r \b / , // rsync with destructive flags
448455 / \b r m d i r \s + - p \s + \/ / , // recursive directory removal from root
449456 / \b s e t c a p \b / , // set file capabilities
@@ -460,12 +467,11 @@ export function isPotentiallyDangerousCommand(command: string): boolean {
460467 / \b d d \s + i f = \/ d e v \/ z e r o \b / , // zero out disk
461468 / \b m k t e m p \b .* - d \b / , // temporary directory overwrite
462469 / \b l s o f \b .* \/ d e v \/ / , // listing open devices
463- / \b k i l l \s + - C O N T \b / , // resuming stopped processes forcefully
464- / \b c h m o d \s + 7 7 7 \b / , // any chmod 777
465- / \b c h o w n \s + - R \b .* \/ h o m e \/ \S + / , // recursive home ownership change
466- / \b s e r v i c e \s + .* s t o p \b / , // stop services
467- / \b s e r v i c e \s + .* r e s t a r t \b / , // restart services
468470 / \b e x p o r t \s + P A T H = .* \/ b i n \b / , // overwrite path to binaries
471+ / \b t c p d u m p \b / , // packet sniffer
472+ / \b t s h a r k \b / , // another packet sniffer
473+ / \b i f d o w n \b | \b i f u p \b / , // bring network interfaces up or down
474+ / \b c a t \s + \/ e t c \/ p a s s w d / , // read passwd file
469475
470476 // ===== Windows PowerShell / CMD =====
471477 / \b s t o p - p r o c e s s \b / i, // stop processes
@@ -508,6 +514,7 @@ export function isPotentiallyDangerousCommand(command: string): boolean {
508514 / \b N e w - N e t F i r e w a l l R u l e \b / i, // Create new firewall rules
509515 / \b R e m o v e - N e t F i r e w a l l R u l e \b / i, // Remove firewall rules
510516 / \b S t o p - S e r v i c e \b / i, // Stop a service
517+ / \b S t a r t - S e r v i c e \b / i, // Start a service
511518 / \b R e m o v e - S e r v i c e \b / i, // Remove a service
512519 / \b S e t - S e r v i c e \b / i, // Change service properties
513520 / \b G e t - C i m I n s t a n c e \s + W i n 3 2 _ S e r v i c e \s * \| \s * I n v o k e - C i m M e t h o d \s + - M e t h o d N a m e \s + S t o p S e r v i c e \b / i, // Stop service using CIM
@@ -536,6 +543,12 @@ export function isPotentiallyDangerousCommand(command: string): boolean {
536543 / \b R e m o v e - W i n d o w s F e a t u r e \b / i, // removing features
537544 / \b R e m o v e - W i n d o w s C a p a b i l i t y \b / i, // dangerous capability removal
538545 / \b C l e a r - H o s t \b / i, // could hide terminal evidence
546+ / \b S e t - I t e m P r o p e r t y \b .* R u n / , // add to startup
547+ / \b G e t - W m i O b j e c t \s + - C l a s s \s + W i n 3 2 _ S t a r t u p C o m m a n d \b / i, // get startup commands
548+ / \b I n v o k e - W e b R e q u e s t \b / i, // web request (could be used for C2)
549+ / \b ( w g e t | c u r l | i w r ) \s + .* \. ( e x e | p s 1 | b a t | v b s ) / i, // download and execute
550+ / \b $ e n v : A P P D A T A / i, // reference to user's appdata
551+ / \b G e t - W m i O b j e c t \s + W i n 3 2 _ C o m p u t e r S y s t e m \b .* - I n v o k e M e t h o d \b / i, // WMI system control
539552 ] ;
540553
541554 return dangerousPatterns . some ( ( pattern ) => pattern . test ( command ) ) ;
0 commit comments