summaryrefslogtreecommitdiff
path: root/src/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexec')
-rw-r--r--src/libexec/deddos.c53
-rw-r--r--src/libexec/httpd.c13
-rw-r--r--src/libexec/peerip.c13
3 files changed, 75 insertions, 4 deletions
diff --git a/src/libexec/deddos.c b/src/libexec/deddos.c
new file mode 100644
index 0000000..245ba41
--- /dev/null
+++ b/src/libexec/deddos.c
@@ -0,0 +1,53 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <signal.h>
+
+void ignore(int a) {}
+
+int main(int argc,char *argv[]) {
+ int i;
+ struct sockaddr sa;
+ signal(SIGALRM,exit);
+ alarm(10);
+ int sl=sizeof(sa);
+ char host[256];
+ char serv[256];
+ char cmd[256];
+ char line[256];
+ char iface[256];
+ char *name[16];
+ getpeername(0,&sa,&sl);
+ //this function is nifty as shit.
+ getnameinfo(&sa,sl,host,256,serv,256,NI_NUMERICHOST);
+ printf("connecting from: %s port %s\n",host,serv);
+ fflush(stdout);
+ printf("select interface:\n");
+ fflush(stdout);
+ system("/bin/cat /etc/interfaces | /usr/bin/tr '\n' ' ' | /usr/bin/fold");
+ fflush(stdout);
+ fgets(iface,sizeof(iface)-1,stdin);
+ for(i=0;iface[i];i++) {
+ if((iface[i] >= 'a' && iface[i] <= 'z') || (iface[i] >= '0' && iface[i] <= '9')) {
+
+ } else {
+ iface[i]=0;
+ }
+ }
+ alarm(60);
+ name[0]="/usr/sbin/tcpdump";
+ name[1]="-c10";
+ name[2]="-ni";
+ name[3]=iface;
+ name[4]="host";
+ name[5]=host;
+ name[6]="and";
+ name[7]="proto";
+ name[8]="UDP";
+ name[9]=0;
+ execv(name[0],name);
+ printf("shit fucked.\n");
+}
diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c
index 4b14269..9da149f 100644
--- a/src/libexec/httpd.c
+++ b/src/libexec/httpd.c
@@ -2,13 +2,15 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+#include <syslog.h>
#define VHOST_ROOT "/var/www"
#define CGI "cgi-bin"
#define SERVER "epochttpd/2.0 (Unix)"
void standard_headers() {
- printf("Server: %s\n",SERVER);
+ printf("Server: %s\r\n",SERVER);
+ printf("Connection: close\r\n");
}
int main(int argc,char *argv[]) {
@@ -22,6 +24,8 @@ int main(int argc,char *argv[]) {
char *get_param;
char line[getpagesize()];
fgets(line,sizeof(line)-1,stdin);
+// syslog(LOG_INFO,"ADDRESS did a LINE");
+// syslog(LOG_WARNING,"httpd syslog test\n");
if(!strchr(line,'\n')) {
printf("HTTP/1.1 413 Entity Too Large\r\n");
standard_headers();
@@ -71,7 +75,7 @@ int main(int argc,char *argv[]) {
printf("Location: /%sindex.html\r\n\r\n",page);
return 0;
}
- if(fd=open(page,O_RDONLY) != -1) {//need to check that the file isn't a directory. :P
+ if((fd=open(page,O_RDONLY)) != -1) {//need to check that the file isn't a directory. :P
printf("HTTP/1.1 200 OK\r\n");
standard_headers();
name[0]="/usr/local/bin/mime-type";
@@ -92,8 +96,9 @@ int main(int argc,char *argv[]) {
wait(&s);
fflush(stdout);
printf("\r\n");
- while((n=read(fd,line,sizeof(line))) > 0) {
- write(1,line,n);
+ fflush(stdout);
+ while((n=read(fd,line,sizeof(line)-1)) > 0) {
+ write(STDOUT_FILENO,line,n);
}
} else {
printf("HTTP/1.1 404 Not Found\r\n");
diff --git a/src/libexec/peerip.c b/src/libexec/peerip.c
new file mode 100644
index 0000000..d35aca7
--- /dev/null
+++ b/src/libexec/peerip.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+int main(int argc,char *argv[]) {
+ int i;
+ struct sockaddr sa;
+ int sl=sizeof(sa);
+ char host[256];
+ getpeername(0,&sa,&sl);
+ getnameinfo(&sa,sl,host,256,0,0,NI_NUMERICHOST);
+ puts(host);
+}