리눅스상에서 패킷을 바로 보내는 방법이 있을까요?

gnoygnas의 이미지

이더리얼과 TCP DUMP로 패킷을 캡춰한후 아래와 같이 BigEndian 방식으로 버퍼를 만들어 놓았습니다.
버퍼안에는 이더넷, TCP/IP 등의 모든 정보를 넣어두었습니다.

목적은 TCP를 사용해서 Syn, Syn+Ack, ACK의 3way 핸드세이킹을 제대로 하는지 검증해보고 싶어서 입니다.

클라이언트에서 Syn을 보내면 서버에서 Syn+Ack, 다시 클라이언트에서 Ack를 보내는 프로그램을 짜려고 하는데 리눅스에서 바로 하단의 함수를 건드려 보낼 수 있는지 궁금합니다.

도움 주시면 고맙겠네요..^^

char tcp_syn_buf[74]={
		0xd0, 0x00, 0xf1, 0xca, 0x21, 0x26, 0x0c, 0x00,     0x25, 0x29, 0x21, 0x1e, 0x00, 0x08, 0x00, 0x45,
		0x3c, 0x00, 0xbc, 0xd3, 0x00, 0x40, 0x06, 0x40,     0xec, 0xe1, 0x16, 0x01, 0xa8, 0xc0, 0x63, 0x01,
		0xa8, 0xc0, 0x1b, 0x04, 0x24, 0x21, 0x3a, 0xef,     0x72, 0xb9, 0x00, 0x00, 0x00, 0x00, 0x02, 0xa0,
		0xd0, 0x16, 0x0f, 0xa1, 0x00, 0x00, 0xb4, 0x05,     0x04, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00,
		0x86, 0x3c, 0xa2, 0x00, 0xa0, 0x80, 0x00, 0x03,     0x03, 0x01
};

char tcp_synack_buf[74]={
		0xd0, 0x00, 0xc0, 0x59, 0x08, 0xb0, 0xd0, 0x00,     0xf1, 0xca, 0x21, 0x26, 0x00, 0x08, 0x00, 0x45,
		0x3c, 0x00, 0xbc, 0xd3, 0x00, 0x40, 0x06, 0x40,     0xa9, 0xb5, 0x63, 0x01, 0xa8, 0xc0, 0x16, 0x01, 
		0xa8, 0xc0, 0x24, 0x21, 0x1b, 0x04, 0xd0, 0x78,     0xbb, 0xa4, 0x3b, 0xef, 0x72, 0xb9, 0x12, 0xa0, 
		0xa0, 0x16, 0x40, 0x65, 0x00, 0x00, 0xb4, 0x05,     0x04, 0x02, 0x02, 0x04, 0x86, 0x3c, 0x00, 0xa2, 
		0x61, 0x1e, 0x01, 0x00, 0x0a, 0x08, 0x00, 0x03,     0x03, 0x01
};

char tcp_ack_buf[66]={
		0xd0, 0x00, 0xf1, 0xca, 0x21, 0x26, 0xd0, 0x00,     0xc0, 0x59, 0x08, 0xb0, 0x00, 0x08, 0x00, 0x45,
		0x34, 0x00, 0xbd, 0xd3, 0x00, 0x40, 0x06, 0x40,     0xf3, 0xe1, 0x16, 0x01, 0xa8, 0xc0, 0x63, 0x01,
		0xa8, 0xc0, 0x1b, 0x04, 0x24, 0x21, 0x3b, 0xef,     0x72, 0xb9, 0xd1, 0x78, 0xbb, 0xa4, 0x10, 0x80,
		0xd0, 0x16, 0xd5, 0x93, 0x00, 0x00, 0x01, 0x01,     0x00, 0x00, 0x00, 0x00, 0x86, 0x3c, 0xa2, 0x00,
		0xa0, 0x80
};
쌀밥의 이미지

제 기억이 맞다면

SYN과 ACK 정보를 담은 패킷을 보내기 위해서는 커널 레벌의 코드를 수정하지 않으면 안됩니다.

이렇게 되는 이유는 .. 일반 App 레벨에서 이런 조작이 가능해지면 보안과 관련된 문제가 발생하기 때문으로 알고 있습니다.

일하는 사람들의 희망 민주노동당 : http://www.kdlp.org
반공 교육의 성과로, 민주주의의 반대가 공산주의(또는 사회주의)라고 생각하는 사람이 많다.

cocas의 이미지

socket 을 만들 떄 보통 RAW 소켓으로 만드시면 커널에서 Link Layer까지만 처리합니다. TCP/IP 헤더를 직접 구성하실 수 있습니다. 당연히 root만 가능합니다. :)

http://kali.kaist.ac.kr/~genesis/tt/attach/1205/051205234854009544/199668.jpg

갑자기 위 그림이 생각나네요. :)

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.