[급질] 넷필터를 이용한 MSN메신저 차단 모듈 작성중 문제 입니다. 도와주세요.

choosh83의 이미지

안녕하세요.

작업중인 커널 버젼은 Redhat9, 2.4.20입니다.

넷필터를 이용하여 들어오는 패킷의 포트와 MSN메신저의 포트를 비교하여 같으면 해당 패킷을 드랍하여

메신저를 차단하는 모듈을 개발하는 중입니다.

현재 모듈을 올린 상태에서는 정상적인 메세지 차단이 이루어 집니다.

하지만 모듈을 내리게 되면 그동안 쌓였던 메세지가 한번에 주루룩 찍히는 현상이 발생합니다.

이더리얼을 가지고 패킷을 검사해보니 제대로 DROP되지 않고 계속 패킷이 상주해 있는듯 합니다.

정말 이것저것 다 뒤져보고 찾아보았지만 해결책을 찾지못해 이렇게 조언을 구합니다.

제가 시도해본 방법은

1. PORT번호를 비교하여 return NF_DROP; 하는 방법
2. PORT번호를 비교하여 해당 포트이면 sk_buff의 port번호를 강제로 변환하여 넘겨주는 방법
3. PORT번호를 비교하여 해당 포트이면 sk_buff를 memset으로 0으로 초기화 시키는 방법

등.. 입니다. 모두 결과는 같았습니다.

도와주세요. 그럼.. 긴글 읽어 주셔서 감사합니다.

아래는 PORT번호를 비교하여 DROP하는 소스 입니다.

---------------------------------------------------------------------------------------

#include
#include
#include
#include
#include
#include
#include
#include

#define MSN_PORT 1863

unsigned int hook_simple ( unsigned int hook_no,
struct sk_buff **pskb,
const struct net_device *dev_in,
const struct net_device *dev_out,
int (*handler)(struct sk_buff*))
{
struct iphdr *ip = (struct iphdr*) (*pskb)->nh.iph;
struct tcphdr *th = (struct tcphdr *)( (*pskb)->data + (ip->ihl * 4));
char *data = NULL;
int length = 0;
unsigned short src, dst;
unsigned int tt;
unsigned char local_ip_s;
unsigned char local_ip_d;

src = ntohs(th->source);
dst = ntohs(th->dest);
if ( src == MSN_PORT || dst == MSN_PORT){
printk(KERN_ALERT "MSN !!!\n");

return NF_DROP;
}

return NF_ACCEPT;
}


static struct nf_hook_ops nfilter_in =
{
.hook = hook_simple,
.pf = PF_INET,
.hooknum= NF_IP_LOCAL_IN,
.priority= NF_IP_PRI_LASTstatic struct nf_hook_ops nfilter_out =
{
.hook = hook_simple,
.pf = PF_INET,
.hooknum= NF_IP_LOCAL_OUT,
.priority= NF_IP_PRI_LAST
};



int nfilter_init ( void)
{
nf_register_hook( &nfilter_in);
nf_register_hook( &nfilter_out);

printk( KERN_ALERT "[Kernel] NFilter Init.\n");void nfilter_exit ( void)
{
nf_unregister_hook ( &nfilter_in);
nf_unregister_hook ( &nfilter_out);

printk( KERN_ALERT "[Kernel] NFilter Exit.\n");
}

module_init( nfilter_init);
module_exit( nfilter_exit);
MODULE_LICENSE( "Dual BSD/GPL");

return 0;
}

댓글 달기

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