diff options
| author | epoch <epoch@enzo.thebackupbox.net> | 2021-10-25 07:42:50 +0000 | 
|---|---|---|
| committer | epoch <epoch@enzo.thebackupbox.net> | 2021-10-25 07:43:14 +0000 | 
| commit | d5fd6ce0bad91b1cd2e76515e1259fa6c93665a7 (patch) | |
| tree | 4825c9798f6ac9047eb927e5fa2d004676074a0a | |
| parent | 6bc244ea4584b97a7ba514d4110f43ee30be0515 (diff) | |
| download | uritools-d5fd6ce0bad91b1cd2e76515e1259fa6c93665a7.tar.gz uritools-d5fd6ce0bad91b1cd2e76515e1259fa6c93665a7.zip | |
added a program to convert a string with single-quotes into a shell-escaped version because writing that same sed regex over and over was a pain in the ass. also added a ssh handler. read before use. put them in Makefile
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | sqesc.c | 18 | ||||
| -rwxr-xr-x | ssh_hack | 26 | 
3 files changed, 46 insertions, 0 deletions
| @@ -24,6 +24,8 @@ clean:  	rm -f *.o  install: all +	install -t $(PREFIX)/bin sqesc +	install -t $(PREFIX)/bin ssh_hack  	install -t $(PREFIX)/bin xwindowURI  	install -t $(PREFIX)/bin uriqueryfilter  	install -t $(PREFIX)/bin urimatch @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <string.h> + +int print_escaped(char *s) { +  char *p=0; +  for(p=strchr(s,'\'');p && s && *p && *s;p=strchr(s,'\'')) { +    *p=0;//null out this single-quote +    printf("%s",s); +    printf("'\\''"); +    s=p+1; +  } +  printf("%s",s); +  return 0; +} + +int main(int argc,char *argv[]) { +  return print_escaped(argv[1]); +} diff --git a/ssh_hack b/ssh_hack new file mode 100755 index 0000000..e882cd2 --- /dev/null +++ b/ssh_hack @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +### we need to export each of the query string variables +### then send them over ssh +q="$(printf "%s\n" "$1" | uricut -q)" +p="$(printf "%s\n" "$1" | uricut -p)" +d="$(printf "%s\n" "$1" | uricut -d)" +P="$(printf "%s\n" "$1" | uricut -P)" +u="$(printf "%s\n" "$1" | uricut -u)" + +eval "$(printf '%s\n' "$q" | tr '&' ' ' | grep '[^ ]*=' | sed 's/^/export /g')" +if [ "$p" ];then +  p="$(uriunescape "$p")" +fi +if [ "$P" ]; then +  HACK_PORT="-p $P" +fi +if [ "$u" ];then +  HACK_USER="$u@" +fi + +tmpfile=$(mktemp); +printf '%s\n' "$q" | tr '&' '\n' | cut -d= -f1 | sed 's/^/SendEnv /g' > "$tmpfile" + +ssh -F "$tmpfile" -t ${HACK_PORT} ${HACK_USER}${d} ${p:1} +#ssh -F <(printf '%s\n' "$q" | tr '&' '\n' | cut -d= -f1 | sed 's/^/SendEnv /g') -t ${HACK_PORT} ${HACK_USER}${d} ${p:1} +#ssh -F <(printf '%s\n' "$q" | tr '&' '\n' | cut -d= -f1 | sed 's/^/SendEnv /g') -t ${HACK_PORT} ${HACK_USER}${d} ${p:1} | 
