summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/mcast-raw.c21
-rw-r--r--src/bin/mcast.c26
-rw-r--r--src/bin/supersu.c35
3 files changed, 82 insertions, 0 deletions
diff --git a/src/bin/mcast-raw.c b/src/bin/mcast-raw.c
new file mode 100644
index 0000000..81913d3
--- /dev/null
+++ b/src/bin/mcast-raw.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+int main(int argc,char *argv[]) {
+ int s=socket(AF_INET,SOCK_RAW,atoi(argv[2]));
+ char packet[1501];//mtu of an interface. including headers though. meh.
+ int n;
+ struct ip_mreq mreq;
+ struct sockaddr_in sa;
+ int one = sizeof(struct sockaddr_in);
+ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+ mreq.imr_multiaddr.s_addr=inet_addr(argv[1]);
+ mreq.imr_interface.s_addr=htonl(INADDR_ANY);
+ setsockopt(s,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq));
+ while((n=recvfrom(s,packet,sizeof(packet),0,(struct sockaddr *)&sa,&one)) > 0) {
+ printf("%s ",inet_ntoa(sa.sin_addr));
+ fflush(stdout);
+ write(1,packet,n);
+ }
+}
diff --git a/src/bin/mcast.c b/src/bin/mcast.c
new file mode 100644
index 0000000..e48c504
--- /dev/null
+++ b/src/bin/mcast.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+int main(int argc,char *argv[]) {
+ int s=socket(AF_INET,SOCK_DGRAM,0);
+ char packet[1501];//mtu of an interface. including headers though. meh.
+ int n;
+ struct ip_mreq mreq;
+ struct sockaddr_in sa;
+ int one = sizeof(struct sockaddr_in);
+ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+ memset(&sa,0,sizeof(struct sockaddr_in));
+ sa.sin_addr.s_addr=htonl(INADDR_ANY);
+ sa.sin_port=htons(atoi(argv[2]));
+ sa.sin_family=AF_INET;
+ bind(s,(struct sockaddr *)&sa,sizeof(struct sockaddr_in));
+ mreq.imr_multiaddr.s_addr=inet_addr(argv[1]);
+ mreq.imr_interface.s_addr=htonl(INADDR_ANY);
+ setsockopt(s,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq));
+ while((n=recvfrom(s,packet,sizeof(packet),0,(struct sockaddr *)&sa,&one)) > 0) {
+ printf("%s ",inet_ntoa(sa.sin_addr));
+ fflush(stdout);
+ write(1,packet,n);
+ }
+}
diff --git a/src/bin/supersu.c b/src/bin/supersu.c
new file mode 100644
index 0000000..d3f7fec
--- /dev/null
+++ b/src/bin/supersu.c
@@ -0,0 +1,35 @@
+#include <stdio.h>
+
+int main(int argc,char *argv[]) {
+ int i;
+ if(argc < 4) {
+ fprintf(stderr,"usage: %s uid gid [secondary_gids] absolute-path-of-executable\n",argv[0]);
+ return 0;
+ }
+ if(getuid() && geteuid()) {
+ fprintf(stderr,"supersu: uid: %d, euid: %d... I have no idea how this is supposed to work. oh well.\n",getuid(),geteuid());
+ }
+ int groups[argc-2];
+ int ngroups=0;
+ char **name;
+ int here=0;
+ for(i=2;i<argc;i++) {
+ if(argv[i][0]=='/') {
+ here=i;
+ break;
+ }
+ }
+ if(here == 0) {
+ fprintf(stderr,"%s: I didn't find an absolute-path in the argument list.\n",argv[0]);
+ return 0;
+ }
+ ngroups=argc-(argc-here)-2;
+ for(i=2;i<here;i++) {
+ groups[i-2]=atoi(argv[i]);
+ }
+ name=argv+i;
+ setgroups(ngroups,groups);
+ setgid(atoi(argv[2]));
+ setuid(atoi(argv[1]));
+ execv(*name,name);
+}