Install byobu Ubuntu Precise

To fix the infinite scrolling issue with byobu and Ubuntu precise install it the following way:

apt-get install byobu echo “at the next prompt select ‘screen’ as the backend” byobu-select-backend

Howto Add Hex Numbers via Command Line

Recently I needed to calculate the starting and ending memory addresses of an IOS application (in order to dump it). As a result i needed to figure out how to add two hex addresses. Here’s what I discovered.

Basic Example

In this case we are adding 0x4f000 and 0×2000

$ printf “0x%X\n” $(( 0x4f000+0×2000 )) . . . → Read More: Howto Add Hex Numbers via Command Line

How to Send Mail From Ubuntu Precise

Configuration

To send mail from the command line in Ubuntu Precise

sudo apt-get install mailutils

If you mess up configuring or want to reconfigure

dpkg-reconfigure mailutils Sending your test email

Let’s send a test email!

echo “test email body” | mail -s “test email subject” [email protected] Debugging issues tail -f /var/log/mail.err tail -f /var/log/mail.log Config . . . → Read More: How to Send Mail From Ubuntu Precise

Logstash Logrotate Howto

Problems

I was facing two problems with my Logstash setup

Logstash service constantly required manual restarts (no longer indexing, hanging process) Local log files were filling up my root partition Symptom

Logstash failed to:

Index events in the queue Trim its own logs =) Cause Indexing

I’m not sure why it was failing to index. . . . → Read More: Logstash Logrotate Howto

Bash Cheat Sheet

Here’s my bash cheat sheet:

Tests Combining [ condition ] && action; # action executes if condition is true. [ condition ] || action; # action executes if condition is false. Filesystem related tests

We can test different filesystem related attributes using different condition flags as follows:

[ -f $file_var ]: Returns true if the . . . → Read More: Bash Cheat Sheet

restart service over ssh

I recently ran in to trouble restarting neo4j over ssh

here’s the fix:

From machine calling neo4j host ssh -f [email protected]$HOST ‘sh -c “( (nohup sudo /etc/init.d/neo4j-service restart 2>&1 >output.file </dev/null) & )”‘ Target Machine Sudoers

Replace “someuser” with whatever user name you want

someuser ALL=NOPASSWD:/etc/init.d/neo4j-service * References starting-remote-script-via-ssh-containing-nohup git-hub-neo4j-issue (I’ve also documented this on . . . → Read More: restart service over ssh

Testing SSL Chaining Issues

Recently I needed to debug an issue by testing SSL chaining issues My old standby tools (curl and openssl were not reporting any errors) The exception javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors Cause The cert from the keystore does not match the cert from . . . → Read More: Testing SSL Chaining Issues

Download a Single File from Amazon S3

How can we easily download a single file from Amazon S3?

Install s3cmd apt-get install ipset Setup s3cmd s3cmd –configure List your buckets and files s3cmd ls Download your file s3cmd get s3://bucket-name//file-name

Whitelist Entire Country with ipset

Goal: Whitelist an Entire Country with ipset For this article i’ll be referencing the github repository I set up at

https://github.com/ssstonebraker/braker-scripts/tree/master/working-scripts/ipset We have a few files there, specifically: * cidr_to_ipset.sh (a script to create an ipset ruleset) * Some example CIDR blocks for Italy (IT.txt), Spain (ES.txt), Great Britian (GB.txt), USA (US.TXT) * sample_firewall.txt (example . . . → Read More: Whitelist Entire Country with ipset

barnyard2 won’t log to database – how to fix it

What to do when barnyard2 won’t log to the database….

Are you seeing something like this?

[SignatureReferencePullDataStore()]: No Reference found in database …

Full text:

# /usr/local/bin/barnyard2 -c /etc/barnyard2.conf -d /var/log/snort -f snort.log -w /var/log/barnyard2/barnyard2.waldo Running in Continuous mode –== Initializing Barnyard2 ==– Initializing Input Plugins! Initializing Output Plugins! Parsing config file “/etc/barnyard2.conf” +[ Signature . . . → Read More: barnyard2 won’t log to database – how to fix it