[C언어, VC]패킷 만드는 방법 궁급합니다.

sepiros의 이미지

[C언어, VC] 환경입니다.

winpcap를 이용해서.. 네트워크 미러링 환경에서... 특정 ip로 패킷을 전송할려고 합니다.

하드웨어적인 문제는 해결이되었는데..

소프트웨어에서 문제가 발생하네요..

winpcap를 이용해서.. 전송할려고 하는데

패킷을. 어떻게.. 만들어야 할지를 모르겠습니다.

어느정도는 알고 있으나.. 막상 구현할려고 보니까...

예를 들어서.

ip_header *ih => 패킷의 헤더부분
u_char data[100] => 보내고자 하는 데이터

이렇게 있을때..

보내고자 하는. 패킷내용은

http://www.devpia.com

이 url을 보내줄려고 하는것입니다..

url을 data에 넣는 방법과..

패킷을.. ih 와 data를 가지고 만드는 방법이 궁금합니다.

도움을 청합니다.

익명 사용자의 이미지

        memset(sendbuf, 0, 2000);
        iph->ip_hl = (sizeof(struct ip)/4);
        iph->ip_v = IPVERSION;
        iph->ip_tos = tos;
        iph->ip_len = sizeof(struct ip) + len;
        iph->ip_id = 0;
        iph->ip_off = 0;
        iph->ip_ttl = 0xff;
        iph->ip_p = IPPROTO_SCTP; //<-이거 바꿔야 될것같은데 잘모르겠네요
        iph->ip_dst.s_addr = dest->sin.sin_addr.s_addr;
        iph->ip_src.s_addr = INADDR_ANY;
        iph->ip_sum = 0;
        /* this is ugly, but it should work */
        memcpy(&(sendbuf[sizeof(struct ip)]), buf, len);
        len += sizeof(struct ip); 
        iph->ip_sum = in_check(sendbuf, len);
        dest_len = sizeof(struct sockaddr_in);

        /* test -- start */
        /* if ((number_of_sendevents % 30) != 0)  { */
        /* test -- stop */

        txmt_len = sendto(sfd, sendbuf, len, 0, (struct sockaddr *) &(dest->sin), dest_len);

linux에서 보낼때는....위와같이 사용합니다.
형식만 참조하세요.... :)

mach의 이미지

winpcapd 를 설치하면 패킷을 전송하는 예제가 있을텐데요?

http://winpcap.polito.it/docs/docs31beta4/html/group__wpcap__tut8.html

* 패킷만을 보내는것이야 어려울것이 없으나, 받는 쪽이 패킷단위 수신이 아니고, UDP, TCP등의 상위 프로토콜을 사용한다면, 프로그램이 아주 복잡해지겠습니다. 코딩도 단순하지 않고요.

------------------ P.S. --------------
지식은 오픈해서 검증받아야 산지식이된다고 동네 아저씨가 그러더라.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.