Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dvnc0 committed Mar 23, 2024
1 parent 3ff660e commit a47fff3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/Gremlins/Black_Hole_Gremlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ class Black_Hole_Gremlin extends Gremlin {
* @return void
*/
public function attack(): void {
$black_hole = fopen('/dev/null', 'w');
fwrite($black_hole, 'Black Hole Gremlin');
$size = rand(1000000, 9999999999);
$random_string = str_repeat('1', $size);
fwrite($black_hole, $random_string);
fclose($black_hole);
$pid = pcntl_fork();
if ($pid === -1) {
$this->writeToLog('Black Hole Gremlin failed to fork');
exit(1);
} elseif ($pid) {
$this->writeToLog('Black Hole Gremlin is attacking the system');
return;
} else {
$black_hole = fopen('/dev/null', 'w');
fwrite($black_hole, 'Black Hole Gremlin');
$size = rand(1000000, 9999999999);
$random_string = str_repeat('1', $size);
fwrite($black_hole, $random_string);
fclose($black_hole);
}
}
}
2 changes: 1 addition & 1 deletion src/Gremlins/Disk_Gremlin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Disk_Gremlin extends Gremlin {

/**
* Attack the system by writing a random amount of data to /dev/null
* Attack the system by writing a random amount of data to disk
*
* @return void
*/
Expand Down

0 comments on commit a47fff3

Please sign in to comment.