Test
Test
( Tech | Security | Linux | Bike | Misc ) ramblings
llama.jpg |
#!/bin/bash
WINDOW=$1
MSG=$2
xdotool windowactivate $WINDOW;
while read -n1 i; do
case $i in
"") i="space" ;;
"\"") i="quotedbl" ;;
"@") i="at" ;;
"-") i="minus" ;;
";") i="semicolon" ;;
esac
xdotool key $i
sleep 0.01
done <<<"$MSG"
xdotool key Return
#include <sys/sendfile.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
//ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
int main(int argc, char **argv){
ssize_t sf_stat;
if (argc != 3){
printf("usage: %s in_file out_file\n", argv[0]);
return -1;
}
int in_fd = open(argv[1], O_RDONLY);
int out_fd = creat(argv[2], S_IRUSR|S_IWUSR);
if ((in_fd | out_fd) < 0){
perror("error opening file");
return -1;
}
do {
sf_stat = sendfile(out_fd, in_fd, NULL, 65536);
} while (sf_stat > 0);
if (sf_stat < 0){
perror("error copying file");
}
close(in_fd);
close(out_fd);
}
[adam@localhost code]$ ./secret
Usage: ./secret password
[adam@localhost code]$ ./secret abc123
ERROR: Incorrect password
[adam@localhost code]$
[adam@localhost code]$ nm -D secret
w __gmon_start__
U __libc_start_main
U printf
U puts
U strlen
U strncmp
[adam@localhost code]$ cat load_me_first.c
#include <stdio.h>
#include <stdlib.h>
int strncmp(const char *cs, const char *ct, size_t count){
printf("[ Non-offical strncmp hit ]\n"
"\tcs = %s\n"
"\tct = %s\n",
cs, ct);
exit(0);
}
[adam@localhost code]$ gcc -shared -o load_me_first.so -fPIC load_me_first.c
[adam@localhost code]$ ls -la *.so
-rwxrwxr-x. 1 adam adam 8065 Nov 10 22:58 load_me_first.so
[adam@localhost code]$ LD_PRELOAD=./load_me_first.so ./secret "if only this was the password"
[ Non-offical strncmp hit ]
cs = qwerty
ct = if only this was the password
[adam@localhost code]$
[adam@localhost code]$ ./secret qwerty
)\ (__)
/ \ (oo)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cow trying out for a part
in the new JAWS movie
[adam@localhost code]$ time ./strcmp_bruter.py
made it.
Tell me and I forget, teach me and I may remember, involve me and I learn.
real 0m0.111s
user 0m0.043s
sys 0m0.050s
[adam@localhost code]$
[adam@localhost gnuplot]$ ping google.com -c 100 -ni 0.2 | awk -F [=\ ] {'print $(NF-1)'} | grep -E "[0-9]" > ping.dat
[adam@localhost gnuplot]$ head -n 5 ping.dat
27.3
22.2
23.2
72.7
26.4
[adam@localhost gnuplot]$ cat ping.gp
#!/usr/bin/gnuplot
set terminal png
set output "ping.png"
set ylabel "Delay (m/s)"
set xlabel "Number"
plot "ping.dat" with lines
[adam@localhost gnuplot]$ ./ping.gp
- set terminal png
- set output "ping.png"
+ set terminal dumb
[adam@localhost ~]$ pacmd list-sinks | grep index -A 1
index: 0
name: <alsa_output.pci-0000_00_03.0.hdmi-stereo-extra1>
--
* index: 1
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
[adam@localhost ~]$
[adam@localhost ~]$ pacmd set-default-sink 0
[adam@localhost ~]$ pacmd list-sink-inputs | grep -Ei "(available|sink|index|application\.name)" | sed s/^[[:space:]]*//g
>>> 1 sink input(s) available.
index: 39
sink: 1 <alsa_output.pci-0000_00_1b.0.analog-stereo>
application.name = "ALSA plug-in [plugin-container.#prelink#.QLz5gf (deleted)]"
[adam@localhost ~]$ pacmd move-sink-input 39 0 > /dev/null
[adam@localhost ~]$ pacmd list-sink-inputs | grep -Ei "(available|sink|index|application\.name)" | sed s/^[[:space:]]*//g
>>> 1 sink input(s) available.
index: 39
sink: 0 <alsa_output.pci-0000_00_03.0.hdmi-stereo-extra1>
application.name = "ALSA plug-in [plugin-container.#prelink#.QLz5gf (deleted)]"
[adam@localhost ~]$ pacmd load-module module-combine-sink sink_name="Combined" slaves=0,1 adjust_time=5
[adam@localhost ~]$ pacmd list-sinks | grep index -A 1
index: 0
name: <alsa_output.pci-0000_00_03.0.hdmi-stereo-extra1>
--
* index: 1
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
--
index: 2
name: <Combined>
[adam@localhost ~]$ pacmd set-default-sink 2
[adam@localhost ~]$ pacmd set-sink-volume 1 0x15000