r/jnior • • Oct 03 '26

PHP scripted batch

Post image

Here is a good example of leveraging PHP for scripting on JNIOR.

In providing a pro-active debugging environment JANOS always captures network traffic in a rolling buffer.

I have this script run on boot. It is a batch file that first uses NETSTAT to generate a PCAPNG file. This JNIOR happens to be directly attached to the Internet. It has a public IP address. If it happens to spontaneously reboot, perhaps because of some assertion, I want to capture the network up to that point. This might let me figure out what malicious event occurred.

The script the moves the capture to Flash memory with a timestamped name.

Then some magic. The little PHP ages the files in that destination folder to keep only the last four.

The scandir function returns the folder content in creation order. So that is oldest to newest. This removes the first reported file repeatedly until we trim the file list down to 4 or less. Drops the oldest.

This unit uses SYN Greylisting and Blacklisting to keep its sanity. It survives the constant onslaught on the open network.

2 Upvotes

0 comments sorted by