PHP real-time system command output

Throwing some notes here for me to remember on having PHP not buffer the output of a long running process so that it provides realtime output to the browser. I tinkered with SSE options and even AJAX/jQuery, but I finally got this to somewhat work reliably. Note that these notes are tested on PHP 8.1 and Apache 2.4. .htaccess This is required to disable buffering at the server level. Make sure to have mod_rewrite enabled. RewriteRule ^(.*)$ $1 [NS,E=no-gzip:1,E=dont-vary:1] PHP <?php ob_implicit_flush(1); echo Continue reading →

#apache

A Port Scanner in C

The following port scanner C code checks approximately 65535 ports in about 15 seconds on-network. #include <stdio.h> #include <stdlib.h> #include <netinet/in.h> #include <string.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <netdb.h> #include <sys/types.h> #include <sys/time.h> #include <sys/ioctl.h> #include <sys/wait.h> #define MAX_PORTS 65535 #define MAX_SOCKETS 1023 // gcc -o Continue reading →

A BOFH Generator in C

// gcc bofh.c -o bofh #include <stdio.h> #include <stdlib.h> #include <time.h> #define NUM_QUOTES 10 const char* bofh_quotes[NUM_QUOTES] = { "No, my powers can only be used for good.", "It must be a hardware problem.", "I'm sorry, we don't support that feature.", "That's a PEBCAK error (Problem Exists Between Chair And Keyboard).", "Have you tried turning it off and on again?", "The BOFH Excuse Server is down.", "It works for me.", "I'm afraid I can't help Continue reading →

Website Performance Analysis and Graphing – Debian NodeJS + Puppeteer + Cacti

Looking to capture some performance metrics for website from the Linux command line and eventually get it into Cacti (RRD). Here are my scattered notes on this process. I'm not very familiar with NodeJS stuff, so I'm documenting from installation of NodeJS on Debian 11 to creating the project. Install NodeJS, Puppeteer and Chromium headless on Debian 11 Install NodeJS curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - apt install -y nodejs Create Project mkdir Continue reading →

#cacti, #google-chrome, #nodejs, #performance

Analyze RDP Disconnection Logs using PowerShell

The PowerShell script is designed to extract information about Remote Desktop Protocol (RDP) local session manager events from the Windows event logs on a RDS host and save it to a CSV file. Script: Get events with EventID 40 from Microsoft-Windows-TerminalServices-LocalSessionManager/Operational Event Log $RDPAuths = Get-WinEvent -LogName 'Microsoft-Windows-TerminalServices-LocalSessionManager/Operational'-FilterXPath '<QueryList><Query Id="0"><Select>*[System[EventID=40]]</Select></Query></QueryList>' [xml[]]$xml Continue reading →

#powershell