You are viewing jackal

Agnus Dei's Journal

> recent entries
> calendar
> friends
> profile
> previous 20 entries

Wednesday, June 17th, 2015
9:53 am - best cgi ever. :) :) :)

The best CGI I've ever written.  :) :) :)

Basically it says take anything posted to this cgi and write it to a datafile with the timestamp (where I have other scripts come and process it).

In this case I'm just having one machine post json files to another (but I don't control the source machine).

This works because apache pipes all incoming data in as standard in, so you can cat it down to a file.  And I return a "Content-type: text/html\n\n" so the sending servers get a "200 OK" response code.



$ more /var/www/html/foo.cgi
#!/bin/sh
TMPFILE=/opt/myproject/incoming/datafile.`/bin/date +%s%3N`  # Epoch time in milliseconds
cat > $TMPFILE ;  printf "Content-type: text/html\n\n"

(comment on this)

Sunday, June 14th, 2015
10:56 pm - Apple + IPV6 = BROKEN !!!!
Can someone please tell me how this IPV6 shit is still happening on macosx when I have ipv6 disabled on ALL interfaces?????

$  sudo networksetup -listallnetworkservices |grep -v asterisk | while read a; do echo -n "$a: " ; sudo networksetup -getinfo "$a" |grep IPv6 ;done
Thunderbolt Ethernet: IPv6: Off
Wi-Fi: IPv6: Off
VPN (L2TP): IPv6: Off
VPN (L2TP) -old: IPv6: Off
Bluetooth DUN: IPv6: Off
Thunderbolt Bridge: IPv6: Off



Notice how it's not a problem with DNS.  DNS is giving me back an IPv4 IP.

brad-allison-mbp:~ brad.allison$ dig +short www.google.com
74.125.30.105
74.125.30.99
74.125.30.106
74.125.30.103
74.125.30.147
74.125.30.104



When I try to connect to that name (www.google.com) I get an IPv6 address that fails.  Repeatedly.  Then suddenly it flips over to an IPv4 address.

brad-allison-mbp:~ brad.allison$ telnet www.google.com 80
Trying 2607:f8b0:4008:804::2004...
Connected to www.google.com.
Escape character is '^]'.
Connection closed by foreign host.

brad-allison-mbp:~ brad.allison$ telnet www.google.com 80
Trying 2607:f8b0:4008:804::2004...
Connected to www.google.com.
Escape character is '^]'.
Connection closed by foreign host.

brad-allison-mbp:~ brad.allison$ telnet www.google.com 80
Trying 2607:f8b0:4008:804::2004...
Connected to www.google.com.
Escape character is '^]'.
Connection closed by foreign host.

brad-allison-mbp:~ brad.allison$ telnet www.google.com 80
Trying 2607:f8b0:4008:804::2004...
Connected to www.google.com.
Escape character is '^]'.
Connection closed by foreign host.

brad-allison-mbp:~ brad.allison$ telnet www.google.com 80
Trying 216.58.219.164...
Connected to www.google.com.
Escape character is '^]'.
^C^C^]
telnet> quit
Connection closed.

(comment on this)

Tuesday, June 9th, 2015
12:22 pm - How to get Root Access on a mac (without knowing any passwords)

*** this is a repost... i wrote this up before when i was showing how to trash a mac ***

Step 1- Shutdown the mac

Step 2- Hold down the "COMMAND" and "S" keys together and press the power button. Continue to hold down the "COMMAND" and "S" keys until you are at a root prompt

Step 3- At the prompt type "mount -uw /"

Step 4- You are now root, you can do whatever you want from here.

Note: If they have put a password on the open firmware you will not be able to do this (like in the Apple Store) but 99.9999% of users do not put passwords on their bootloaders/firmware.

(comment on this)

Friday, May 8th, 2015
8:59 pm
test -f /proc/net/if_inet6 && echo "Running kernel is IPv6 ready"

(comment on this)

Sunday, May 3rd, 2015
9:27 pm - How to get the number of physical CPU's on a mac

$ sysctl -n hw.physicalcpu

4

$ sysctl -n hw.ncpu

8

(comment on this)

Saturday, April 25th, 2015
10:42 pm - How to delete your google search history

Step 1: Sign into your Google account.

Step 2: View your Web & App Activity

Step 3: In the top right corner of the page, click the cog icon and select “Remove Items.”

Step 4: Choose time period for which you want to delete items. To delete your entire history, select “The Beginning of Time.”

Step 5: Click “Remove.”

(comment on this)

Thursday, April 16th, 2015
3:48 pm - Script for getting IOPS of AWS Volume
https://github.com/jackal242/brads_scripts/blob/master/get_aws_volume_iops.sh

(comment on this)

11:45 am - How to get VolumeWriteOps in units of Ops/s from AWS CloudWatch from the command line.
# export PERIOD=3600; aws cloudwatch get-metric-statistics --metric-name VolumeWriteOps --start-time `date -d '1 hour ago' "+%Y-%m-%dT%H:%M:%S"` --end-time `date "+%Y-%m-%dT%H:%M:%S"` --period $PERIOD --namespace AWS/EBS --statistics Sum --dimensions Name=VolumeId,Value=vol-XXXXXXXX --region us-east-1 | grep Sum | egrep -o [0-9.]* | awk -v PERIOD=$PERIOD {'print $1/PERIOD'}
340.86

(comment on this)

Thursday, March 26th, 2015
3:45 pm - So if it's "headless" on a remote server, then why does it have an X11 requirement?
This is the sort of thing that makes me bang my head into my desk.

Trying to convert a bunch of .doc files to .pdf's. I want to use libreoffice to convert them.

I ssh into the remote box and run the command and I get a X11 error:
[%]$ libreoffice --headless --invisible --convert-to pdf --outdir /tmp /tmp/test.doc
/usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display:
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)


Once I enabled X11 Forwarding to the remote server, reconnect with a new session, and it works:
[%]$ libreoffice --headless --invisible --convert-to pdf --outdir /tmp /tmp/test.doc
Gtk-Message: Failed to load module "canberra-gtk-module"
convert /tmp/test.doc -> /tmp/test.pdf using writer_pdf_Export


So if it's "headless" on a remote server, then why does it have an X11 requirement?

(comment on this)

Monday, March 23rd, 2015
11:42 am - Script for getting AWS drive information
Script for getting AWS drive information
[~]# cat /usr/local/devops/bin/get_aws_drive_info
#!/bin/bash
 
for i in `wget -q -O - http://169.254.169.254/latest/meta-data/block-device-mapping/`; do 
 if [ "$i" == "ami" ] ; then
  continue
 fi
 wget -q -O - http://169.254.169.254/latest/meta-data/block-device-mapping/$i; 
 echo : $i; 
done



Results Example:
[~]# /usr/local/bin/get_aws_drive_info
sdf: ebs1
sdg: ebs2
sdh: ebs3
sdw: ebs4
sdx: ebs5
sdy: ebs6
sdz: ebs7
sdb: ephemeral0
sdc: ephemeral1
/dev/xvda: root

(comment on this)

Thursday, March 19th, 2015
5:06 pm - GHOST (note to self)
This is the good write up on GHOST you are looking for:

http://www.openwall.com/lists/oss-security/2015/01/27/9

(comment on this)

Monday, March 16th, 2015
8:56 am - Reformatting the output of tripwire to make it human friendly
The output of tripwire is very difficult to deal with. It makes for pretty reports, and yes I know there's an XML option, but I just wanted a very simple output that's easy to read. Enter sed for the solution:


/usr/sbin/tripwire --check  | sed '/:$/h;/^".*"$/!d;G;s/^"\(.*\)"\n\(.*\)/\2\1/' | sort
Added:/etc/rc.d/init.d/0
Added:/etc/rc.d/init.d/atop
Added:/etc/rc.d/init.d/blk-availability
Added:/etc/rc.d/init.d/boundary-meter
Added:/etc/rc.d/init.d/cloud-config
Modified:/proc/self
Modified:/usr/sbin/accton
Modified:/usr/sbin/addgnupghome
Modified:/usr/sbin/alternatives
Modified:/usr/sbin/anacron
Modified:/usr/sbin/apachectl
Removed:/usr/sbin/makewhatis
Removed:/usr/sbin/tunelp
Removed:/usr/lib/rpm/fileattrs/maven.attr
Removed:/usr/lib/rpm/fileattrs/osgi.attr

(comment on this)

Monday, March 9th, 2015
5:35 pm - Following a series of 302 redirects
# curl -s -L -v www.espn.com 2>&1 |  egrep "Location|HTTP"
> GET / HTTP/1.1
< HTTP/1.1 301 Moved Permanently
< Location: http://espn.go.com/
> GET / HTTP/1.1
< HTTP/1.1 200 OK

(comment on this)

Saturday, February 21st, 2015
11:47 pm - Sort a file by last name / last column

awk '{print $NF, $0}' /tmp/foo |sort | sed 's/[^\ ]*//' |sed 's/[^a-zA-Z]*//'

(comment on this)

Thursday, February 5th, 2015
12:49 pm - Commands needed to Automate Addition of Encrypted EBS LVM volume
I wrote a perl script to do all this automatically for you  ---> https://github.com/jackal242/brads_scripts/blob/master/attach_encrypted_volume.pl



Keep in mind what Amazon calls /dev/sdp will get renamed to /dev/xvdp under the Linux kernel.

There are just the commands needed.  And the reason you see ec2-describe-volumes repeated is because i keep running it until i see it's online.  And then again inside a loop until I see it's "Attached".


/usr/local/ec2/bin/ec2-create-volume -s 60 --region us-west-2 --encrypted -t gp2 -z us-west-2a              
/usr/local/ec2/bin/ec2-create-tags --region us-west-2 vol-90210abc --tag "Name=hostname-foo-01:/dev/sdp:60GB-volume"
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
/usr/local/ec2/bin/ec2-attach-volume vol-90210abc -i i-abcdefgh --region us-west-2 -d /dev/sdp
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
/usr/local/ec2/bin/ec2-describe-volumes --region us-west-2 vol-90210abc
ssh -l root hostname-foo-01 fdisk -l |grep -A5 /dev/xvdp
ssh -l root hostname-foo-01 /sbin/pvcreate /dev/xvdp
ssh -l root hostname-foo-01 /sbin/pvscan
ssh -l root hostname-foo-01 /sbin/vgcreate autovg00 /dev/xvdp
ssh -l root hostname-foo-01 /sbin/lvcreate -l 100%VG -n lv00 autovg00
ssh -l root hostname-foo-01 /sbin/mkfs -t ext4 /dev/autovg00/lv00
ssh -l root hostname-foo-01 /usr/bin/file -sL /dev/autovg00/lv00
ssh -l root hostname-foo-01 mkdir -p /encrypted
ssh -l root hostname-foo-01 /bin/mount /dev/autovg00/lv00 /encrypted

(comment on this)

Thursday, January 29th, 2015
9:38 am - Office Fan
Worlds best office fan.  Super Super Super quiet.

http://www.amazon.com/O2-Cool-Battery-Operated-Portable/dp/B00CAO2VQK/ref=sr_1_7?ie=UTF8&qid=1422542156&sr=8-7&keywords=o2-cool+fan

(comment on this)

Tuesday, January 27th, 2015
1:20 am - Facebook is down
Facebook is down.

Completely down down down.

(comment on this)

Saturday, January 10th, 2015
11:15 pm - Get your Edit Privacy URLS


STEP 1:

Testing 2010-01-11 (1263186000 to 1263272400)


# curl -s -b cookie.txt -c cookie.txt "https://m.facebook.com/807540200/allactivity?timeend=1263186000&timestart=1263272400" | egrep -o "a class[^<]+" |grep "Edit Privacy" |egrep -o "/privacyx[^\"]+" |  sed "s/amp;//g"
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=295437952648&ct=4&as=1&gfid=AQDwiEZYWJ6oonti
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=304176123102&ct=4&as=1&gfid=AQAHrbp9uRZXtvzj
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=310596156214&ct=4&as=1&gfid=AQA0p1GaaGqt-A85
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=279089747694&ct=4&as=1&gfid=AQBwh-DzkNd4md_I
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=282013462469&ct=4&as=1&gfid=AQAqGDL_7b0SwPgw
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=321065103708&ct=4&as=1&gfid=AQCKG9i02iE6BexA
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=318409680568&ct=4&as=1&gfid=AQBZIzdS-KTrHVkn
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=316021305129&ct=4&as=1&gfid=AQDv7Z6211lrrQjB
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=310989246557&ct=4&as=1&gfid=AQAifFiqUsnL_j0o
/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2F807540200%2Fallactivity%3Ftimeend%3D1263186000%26timestart%3D1263272400&ci=276772527701&ct=4&as=1&gfid=AQDoCnTN1Yk_h2sW

STEP 2

# curl -s -b cookie.txt -c cookie.txt "https://m.facebook.com/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2Fbrad.allison%3Fv%3Dfeed&ci=10155163058820201&ct=4&sel=300645083384735&as=1&gfid=AQA2_qXa3wowH6FI&refid=17&_ft_" | egrep -o "Friends.*Only Me" | egrep -o "/a/privacy[^\"]+" | sed "s/amp;//g"
/a/privacy/?px=286958161406148&cnf=10155163058820201&rd=https%3A%2F%2Fm.facebook.com%2Fbrad.allison%3Fv%3Dfeed&ist=4&gfid=AQCmxT1xPFZEaoyh

STEP 3

# curl -s -b cookie.txt -c cookie.txt "https://m.facebook.com/a/privacy/?px=286958161406148&cnf=10155163058820201&rd=https%3A%2F%2Fm.facebook.com%2Fbrad.allison%3Fv%3Dfeed&ist=4&gfid=AQCmxT1xPFZEaoyh

(comment on this)

11:02 pm - Changing the privacy settings to Only Me
# curl -s -b cookie.txt -c cookie.txt "https://m.facebook.com/privacyx/selector/?redir=https%3A%2F%2Fm.facebook.com%2Fbrad.allison%3Fv%3Dfeed&ci=10155163058820201&ct=4&sel=300645083384735&as=1&gfid=AQA2_qXa3wowH6FI&refid=17&_ft_" | egrep -o "Friends.*Only Me" | egrep -o "/a/privacy[^\"]+" | sed "s/amp;//g"
/a/privacy/?px=286958161406148&cnf=10155163058820201&rd=https%3A%2F%2Fm.facebook.com%2Fbrad.allison%3Fv%3Dfeed&ist=4&gfid=AQCmxT1xPFZEaoyh

(comment on this)

10:43 pm - Deleting any facebook post:
Deleting any facebook post:

$ curl -s -b cookie.txt -c cookie.txt "https://m.facebook.com/delete.php?perm&story_permalink_token=S%3A_I807540200%3A10155162973905201" | egrep -o "/a/[^\"]+" | sed "s/amp;//g"
/a/delete.php?perm&story_permalink_token=S%3A_I807540200%3A10155162973905201&gfid=AQDCGe6rHXBjMk14

Then call that URL that's returned and the post is deleted.

(comment on this)


> previous 20 entries
> top of page
LiveJournal.com