Giter Site home page Giter Site logo

libpgen's People

Contributors

123456f101 avatar lambdasawa avatar shunk031 avatar slankdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libpgen's Issues

各パケットクラスにhelpメンバ関数を追加

ドキュメントに記述してもいいが、scapyみたいに簡単にパケットのプロトコルフィールドと、設定方法を閲覧できるように情報出力をするメンバ関数を追加する。
help関数はpgen_packetクラスの純粋仮想関数としてプロトタイプさせる。

General Install Way

At now, the way to install libpgen with make install is specific to some linux destribution and OSX.
Studying about difference each OS and rewrite makefile

機能分担をしっかり関数単位で分ける

  • pgen_recv_from_netif(int fd, void* buf, int len);
  • pgen_recv_from_pcap(FILE* fp, void* buf, int len);
  • pgen_send_to_netif(int fd, void* buf, int len);
  • pgen_send_to_pcap(FILE* fp, void* buf, int len);

を実装して、パケットの入出力を完全に分担する。
それぞれの関数は一つのパケットのバイナリを渡して、それを処理する関数である。

Make function list

pgen has many functions. I will make the list that is usage of function and infomation of one.
I must write function type, it is pgen-syscall of not.

pcapng descriptor has Unintelligible

I found unintelligible problem. If I write program that open 2 two descriptors, the program can't write to file. I thought about this error for 6 hours today, but I couldn't fix this problem. please help.,..... (T , T)

This program fails to write packet to pcap.

    #include <pgen.h>
    #include <stdio.h>

    int main(int argc, char** argv){
        pgen_t* w = pgen_open_offline("write.pcap", PCAP_WRITE);
        pgen_t* handle = pgen_open("en0", NULL);
        if(handle==NULL || w==NULL){
            pgen_perror("oops");
            return -1;
        }

        u_char buf[1000];
        int buflen;
        while(1){
            buflen = pgen_recvpacket_handle(handle, buf, sizeof(buf));
            if(buflen < 0){
                pgen_perror("oops");
                break;
            }else if(buflen == 0){
                printf("fin \n");
                break;
            }
            pgen_unknown b(buf, buflen);
            if(b.isUDP() && b.UDP.port()==53){
                buflen= pgen_sendpacket_handle(w , b.byte(), b.length());
            }
        }
        pgen_close(handle);
        pgen_close(w);
    }

ドキュメント作成

ドキュメントを早急に作成する。
作成したら、数人に読んでもらって修正する。

BSD向けのコードをnetutils追加する

MBPで作業することが多くなってきたので、BSD向けのnetutilsのコードを追加する。
まずはlinuxでしかコンパイルできないコードをifdefで除外して、BSD向けのifdefの枠組みをついかしてからコードを書く。
前半の作業はlinuxでやって、後半はmacでやる。

Get statistical data from PGEN-descriptor

I want function that gets statistical data from PGEN-descriptor.

Implementation example)

    pgen_t* handle = pgen_open_offline("in.pcapng", PCAPNG_READ);
    if(handle == NULL){
        pgen_perror("oopes");
        return -1;
    }
    struct pgen_statistics ps;
    u_char buf[1000];
    int buflen;
    while(1){
        buflen = pgen_recvpacket_handle(handle, buf, buflen);
        if(buflen < 0){
            pgen_perror("oops");
            break;
        }else if(buflen == 0){
            break;
        }
    }
    pgen_getstatistic(handle, &ps);
    pgen_close(handle);

I'm going to implement new function that gets statistical data. However, I didn't decide function specification. 1st, I have to decide one.

IP header Check-Sum doesn't live

In pgen_ip class and many classes that inherited it, IP header's check sum is always 0x0000.
Re implementation get_checksum function, and use it.

バイナリ生成部分のチェック機能

int check(const char* filename);
を作成して、pcapファイルのパケットを読み込んで一つ一つバイナリ生成をして、元のバイナリと同じかを確認する。

返り値は比較で違う値がでてしまったパケットの数を返す。

Support pcapNG files

Support pcapNG files. add functions to PGEN-Util

Implement These Functions

  • int pgen_send_to_pcapng(FILE_, const void_, int)
  • int pgen_recv_from_pcapng(FILE* , void*, int)

Add some Codes to them

  • pgen_open_offline(pgen_t*, int)
    Being able to open and operate pcapng files.
  • pgen_close()
  • struct pgen; parameter about file-type that is pcap or pcapng

Add some Structure to pgen-types.h

  • struct pgen_pcapng_pkthdr; ,, and more

Add More Member on ARP and IP

Add more values about ARP's hardware-type, protocol-type, hardware-length, protocol-length and IP's flag.

  • ARP.hwtype
  • ARP.ptype
  • ARP.hwlen
  • ARP.plen
  • IP.flags

パケットクラス全体がうまく動作しているかを確認するサンプルコードを追加

機能が増えてきて全体を確認するのが難しくなってきたのでそれを確認するスクリプトを作成する。
各プロトコルごとにパケットを生成してそのバイナリをファイル出力してその値があらかじめ用意していたバイナリファイルと同じになるかを確認すれば、各プロトコルのチェックをすることができる。

エラー番号を追加

各関数でエラー処理をするためにエラー番号を追加する。
pgen_erronoみたいなグローバル変数を使ってたくさんのエラーに対応させる。
pgen_perror(const char*);でエラー出力をできるようにする。

READMEを修正

READMEを修正する。現在廃止した機能とかの説明とかもあるので、それらをなくすことと。

arpテーブルの実装

内部実装をまず設計する。
生成した時から、インターフェースを開いて、パケットを受信し続ける使用にするか、パケット受信部分のみ動作させるかなど。
arpテーブルを検索して、データがない場合新たにarpリクエストを送信するなどの機能の設計もする。

Alert if packet may be malformed

If packet may be malformed, packet class alert warning message in pgen_packet::write_bin()

checking at...

  • ip (header len, total len)
  • icmp (ip total len)
  • tcp (data-offset, ip total len)
  • udp (len , ip total len)

Add check-script for PGEN-Core, PGEN-IO

u_char buf[1000];
int buflen;
/* recv packet */

pgen_packet* pack = &arp;
pack->cast(buf, buflen);

if(buflen != pack->len()){
printf("length error \n");
}else{
int res = memcmp(buf, pack->data());
printf("result: %d \n", res);
}

[成功/失敗]系の関数の返す値の規則を決める

intで正負によって成功判断したり、boolで真理値をかえしたりしてるので、なにかしらの判断方式を決定して、以後それに従って開発する。
それを同時進行でエラー番号も勧められる。

char*を返す関数を修正

char* でヌル文字列ポインタを返す関数のコードを修正する。
現在は関数内部でmallocしていて、freeは特に行っていないのでメモリをたくさん無駄使いしている。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.