libxml2

홈페이지: http://xmlsoft.org/

Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), it is free software available under the MIT License. XML itself is a metalanguage to design markup languages, i.e. text language where semantic and structure are added to the content using extra “markup” information enclosed between angle brackets. HTML is the most well-known markup language. Though the library is written in C a variety of language bindings make it available in other environments.

Libxml2 is known to be very portable, the library should build and work without serious troubles on a variety of systems (Linux, Unix, Windows, CygWin, MacOS, MacOS X, RISC Os, OS/2, VMS, QNX, MVS, VxWorks, …)

다운로드: 2.7.8

mintty

http://code.google.com/p/mintty/

msys 에서 rxvt를 버릴수 있게 되었다.

rxvt보다 속도가 빠른것이 맘에든다.

– Xterm-compatible terminal emulation.
– Native Windows user interface with a simple options dialog.
– Easy copy & paste.
– Drag & drop of text, files and folders.
– Ability to open files and URLs with Ctrl+click.
– Comprehensive character encoding support, including UTF-8.
– Wide character display and Windows IME support.
– Window transparency, including glass effect on Vista and 7.
– Options are stored in a text file. No registry entries.
– Small program size and quick scrolling.

위의 홈페이지에서 msys 버전을 받고, msys.bat 에서 아래와 같이 호출한다.

mintty.exe /bin/sh -l

screenshot

libnet

홈페이지: http://mathieu.carbou.free.fr/wiki/index.php?title=Libnet_for_Win32

패킷 생성 라이브리. 반대로 pcap은 패캣 캡쳐 라이브러리.

Libnet이 지원하는 함수
1. 메모리의 패킷 관리 함수
2. 주소 확인 함수
3. 패킷 구조 생성 함수
4. 패킷 생성 함수
5. 기타 지원 함수

Libnet이 지원하는 프로토콜
2계층 : ARP와 이더넷
3계층 : ICMP, IGMP, IPv4
4계층 : TCP, UDP
7계층 : RIP, OSPF, DNS

다운로드: 1.1.3

맥 어드레스만으로 데이타 보내기

MinGW로 컴파일후 테스트.
libnet, winPcap 사용.


// http://tmdgus.tistory.com/86
// http://utensil.javaeye.com/blog/367421


/* HOW TO COMPILE
 
	gcc -I./libnet-mingw-1.1.3-bin/include -I./wpdPack/Include \
		-L./libnet-mingw-1.1.3-bin/lib -L./wpdPack/Lib \
		-g main.c -lnet -lws2_32 -lpacket -lwpcap -lnet -liphlpapi
*/

#include <stdio.h>
#include <stdlib.h>
#include <libnet.h>

char *get_device ()
{
	char *device = NULL;  
	pcap_if_t *alldevs;  
	pcap_if_t *d;  
	int inum;  
	int i=0;  
	char errbuf[PCAP_ERRBUF_SIZE];  

	/* Retrieve the device list */  
	if(pcap_findalldevs(&alldevs, errbuf) == -1)  
	{  
		fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);  
		exit(1);  
	}  


	/* Print the list */  
	for(d=alldevs; d; d=d->next)  
	{  
		printf("%d. %s", ++i, d->name);
		if (d->description)  
			printf(" (%s)\n", d->description);  
		else  
			printf(" (No description available)\n");  
		fflush(stdout);
	}  


	if(i==0)  
	{  
		printf("\nNo interfaces found! Make sure WinPcap is installed.\n");  
		fflush(stdout);
		return NULL;  
	}  


	printf("Enter the interface number (1-%d):",i);  
	fflush(stdout);
	scanf("%d", &inum);  


	if(inum < 1 || inum > i)  
	{  
		printf("\nInterface number out of range.\n");  
		fflush(stdout);
		/* Free the device list */  
		pcap_freealldevs(alldevs);  
		return NULL;  
	}  

	/* Jump to the selected adapter */  
	for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++);  
	
	device = d->name;  

	return device;
}

int main() 
{
	libnet_t *l;    // the libnet context
	char errbuf[LIBNET_ERRBUF_SIZE];
	u_int32_t i, length; // for libnet_hex_aton()
	char payload[] = "libnet :D";
	int bytes_written;
	libnet_ptag_t t;
	
	/*
	 - 윈도우즈의 경우에만 사용
	 - 리눅스의 경우는 device에 "eth0" 를 사용하면 된다.
	*/
	char *device = get_device();
	if ( device == NULL ) return -1;

	l = libnet_init(LIBNET_LINK_ADV, device, errbuf);
	if ( l == NULL ) 
	{
		fprintf(stderr, "libnet_init() failed: %s\n", errbuf);
		exit(EXIT_FAILURE);
	}

	i = libnet_get_ipaddr4(l);

	char enet_src[16];
	char enet_dst[16];
	sprintf(enet_src, "%s", "이곳에 현재 PC의 맥어드레스 기입");
	sprintf(enet_dst, "%s", "이곳에 받을 PC의 맥어드레스 기입");

        // libnet을 이용하면 IP로 맥어드레스를 얻어올수도 있다.

	t = libnet_build_arp(
		ARPHRD_ETHER,                           /* hardware addr */
		ETHERTYPE_IP,                           /* protocol addr */
		6,                                      /* hardware addr size */
		4,                                      /* protocol addr size */
		ARPOP_REPLY,                            /* operation type */
		enet_src,                               /* sender hardware addr */
		(u_int8_t *)&i,                         /* sender protocol addr */
		enet_dst,                               /* target hardware addr */
		(u_int8_t *)&i,                         /* target protocol addr */
		(u_int8_t*)payload,                     /* payload */
		sizeof(payload),                        /* payload size */
		l,                                      /* libnet context */
		0);                                     /* libnet id */
	if (t == -1)
	{
		fprintf(stderr, "Can't build ARP header: %s\n", libnet_geterror(l));
		exit(-1);
	}

	t = libnet_autobuild_ethernet(
		enet_dst,                               /* ethernet destination */
		ETHERTYPE_ARP,                          /* protocol type */
		l);                                     /* libnet handle */
	if (t == -1)
	{
		fprintf(stderr, "Can't build ethernet header: %s\n",
		libnet_geterror(l));
		exit(-1);
	}

	u_int8_t *packet;
	u_int32_t packet_s;
	
    if (libnet_adv_cull_packet(l, &packet, &packet_s) == -1)
    {
        fprintf(stderr, "%s", libnet_geterror(l));
		exit(-1);
    }
    else
    {
        fprintf(stderr, "packet size: %d\n", packet_s);
        libnet_adv_free_packet(l, packet);
    }

    int c = libnet_write(l);
    if (c == -1)
    {
        fprintf(stderr, "Write error: %s\n", libnet_geterror(l));
		exit(-1);
    }
    else
    {
        fprintf(stderr, "Wrote %d byte ARP packet from context \"%s\"; "
                "check the wire.\n", c, libnet_cq_getlabel(l));
    }

    libnet_destroy(l);
	return 0;
}

test

WinPcap

홈페이지: http://www.winpcap.org/

WinPcap is the industry-standard tool for link-layer network access in Windows environments: it allows applications to capture and transmit network packets bypassing the protocol stack, and has additional useful features, including kernel-level packet filtering, a network statistics engine and support for remote packet capture.

패킷 캡쳐 라이브러리
mingw 라이브러리도 포함되어 있다.

최신의 버전에는 패킷을 만들어서 보내는 API도 추가되어 있다.

간단 사용방법: winpcap.txt

런타임 라이브러리: 4.1.2
개발자 라이브러리: 4.1.2

libunicows

홈페이지: http://libunicows.sourceforge.net/

Traditionally, win32 Unicode API was only available on Windows NT or 2000. If you wanted to take advantage of Unicode in your application and support Windows 95/98 at the same time, your only option was to deploy two executables, one for NT and one for 9X. Fortunately, this changed in 2001 when MS (finally!) released MSLU runtime that allows Unicode applications to run under Windows 9X.