summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2015-06-12 22:26:31 -0500
committerepochqwert <epoch@hacking.allowed.org>2015-06-12 22:26:31 -0500
commita05876c9b860f1d5fa786746519ccb8b01db79e3 (patch)
tree8406bd3b42e8e3d7a3f2d56ad1396d62d8f4b1ac
parent05f18ac5c65755e1dde4d4bd44575011310bc648 (diff)
downloadmisc-a05876c9b860f1d5fa786746519ccb8b01db79e3.tar.gz
misc-a05876c9b860f1d5fa786746519ccb8b01db79e3.zip
commit of half-finished things.
-rwxr-xr-xnocompile/bin/rss2
-rw-r--r--nocompile/bin/ssl7
-rw-r--r--src/bin/fontdump.c2
-rw-r--r--src/bin/iplist2cidr.c79
-rw-r--r--src/bin/iprand.c17
5 files changed, 106 insertions, 1 deletions
diff --git a/nocompile/bin/rss b/nocompile/bin/rss
new file mode 100755
index 0000000..3a9e882
--- /dev/null
+++ b/nocompile/bin/rss
@@ -0,0 +1,2 @@
+#!/bin/sh
+wget -qO- https://news.ycombinator.com/rss
diff --git a/nocompile/bin/ssl b/nocompile/bin/ssl
new file mode 100644
index 0000000..4e76122
--- /dev/null
+++ b/nocompile/bin/ssl
@@ -0,0 +1,7 @@
+#!/bin/sh
+#fix this to suit your needs.
+/usr/local/bin/ncat --ssl "$1" "$2"
+
+#I heard this was a bad idea.
+#openssl s_client -q -connect "$1:$2"
+
diff --git a/src/bin/fontdump.c b/src/bin/fontdump.c
index eb481d0..1ed2b05 100644
--- a/src/bin/fontdump.c
+++ b/src/bin/fontdump.c
@@ -10,7 +10,7 @@ int main(int argc,char *argv[]) {
read(0,map,height);
for(j=0;j<height;j++) {
for(k=7;k>=0;k--) {
- printf("%c",(map[j]>>k&1)?'#':' ');
+ printf("%c",(map[j]>>k&1)?'#':'.');
}
printf("\n");
}
diff --git a/src/bin/iplist2cidr.c b/src/bin/iplist2cidr.c
new file mode 100644
index 0000000..b3cc62c
--- /dev/null
+++ b/src/bin/iplist2cidr.c
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <string.h>
+
+struct net {
+ unsigned int ip;
+ unsigned char cidr;
+};
+
+#define min(a,b) ((a)<(b)?(a):(b))
+#define max(a,b) ((a)>(b)?(a):(b))
+
+int main(int argc,char *argv[]) {
+ short in;
+ int maxcidr;
+ int i=0,j=0,len=0;
+ struct net list[65536];//don't do more than a /16!
+ char ips[64];//why not?
+ char *cidrs;
+ while((in=fgetc(stdin)) != -1) {
+ if(in=='\n') {
+ ips[i]=0;
+ if((cidrs=strchr(ips,'/')) != 0) {
+ *cidrs=0;
+ cidrs++;
+ }
+ list[len].ip=htonl(inet_addr(ips));
+ list[len].cidr=cidrs?atoi(cidrs):32;
+ i=0;
+ cidrs=0;
+ len++;
+ continue;
+ }
+ ips[i]=in;
+ i++;
+ if(i>63) {
+ printf("your have a line that is TOOO long. stick to IPv4.\n");
+ return 0;
+ }
+ }
+ //!!!warning!!! inefficient algo ahead!
+ for(i=0;i<len;i++) {
+ for(j=0;j<len;j++) {
+ if(list[i].cidr == list[j].cidr) {
+ if((list[i].ip ^ list[j].ip) >> (32-list[i].cidr) == 1) {
+ list[i].cidr--;
+ list[j].cidr--;
+ list[i].ip &= (0xffffffff << (32-list[i].cidr));
+ list[j].ip &= (0xffffffff << (32-list[j].cidr));
+ i=-1;//start over!
+ j=-1;//start over!
+ continue;
+ }
+ }
+ if(list[i].ip == list[j].ip && list[i].cidr != list[j].cidr) {
+ list[i].cidr = min(list[i].cidr,list[j].cidr);
+ list[j].cidr = min(list[i].cidr,list[j].cidr);
+ i=-1;//start over!
+ j=-1;//start over!
+ continue;
+ }
+ maxcidr=min(list[i].cidr,list[j].cidr);
+ if(list[i].cidr != list[j].cidr) {
+ if(list[i].ip >> (32-maxcidr) == list[j].ip >> (32-maxcidr) ) {
+ list[i].cidr = min(list[i].cidr,list[j].cidr);
+ list[j].cidr = min(list[i].cidr,list[j].cidr);
+ list[i].ip &= (0xffffffff << (32-list[i].cidr));
+ list[j].ip &= (0xffffffff << (32-list[j].cidr));
+ i=-1;//start over!
+ j=-1;//start over!
+ continue;
+ }
+ }
+ }
+ }
+ for(i=0;i<len;i++) {
+ printf("%d.%d.%d.%d/%d\n",list[i].ip>>24&255,list[i].ip>>16&255,list[i].ip>>8&255,list[i].ip&255,list[i].cidr);
+ }
+ return 0;
+}
diff --git a/src/bin/iprand.c b/src/bin/iprand.c
new file mode 100644
index 0000000..e6b2f83
--- /dev/null
+++ b/src/bin/iprand.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <time.h>
+
+int main(int argc,char *argv[]) {
+ srandom(time(0)+getpid());
+ unsigned int ip;
+ unsigned int net=argc>1?htonl(inet_addr(argv[1])):0x0;
+ unsigned int mask=argc>2?htonl(inet_addr(argv[2])):0x0;
+ unsigned int a=argc>3?atoi(argv[3]):3;
+ net &= mask;
+ for(;a>0;a--) {
+ ip=random();
+ ip &= ~mask;
+ ip |= net;
+ printf("%d.%d.%d.%d\n",ip>>24&255,ip>>16&255,ip>>8&255,ip&255);
+ }
+}