블로그 이미지
stluck

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
  • total
  • today
  • yesterday
2012. 8. 25. 21:29 Programming/C/C++/C#
어디서나 볼 수 있는 TCP/IP 예제


Server.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>

void error_handling(char *message);

int main(int argc, char **argv)
{
        int serv_sock;
        int clnt_sock;
        struct sockaddr_in serv_addr;
        struct sockaddr_in clnt_addr;
        int clnt_addr_size;
        char message[] = "Hello sp0ngee!\n";

        if(argc != 2)
        {
                printf("Usage : %s <port>\n", argv[0]);
                exit(1);
        }

        /* 서버 소켓 생성 */
        serv_sock = socket(PF_INET, SOCK_STREAM, 0);
        if(serv_sock == -1)
                error_handling("socket() error");

        memset(&serv_addr, 0, sizeof(serv_addr));

        serv_addr.sin_family = AF_INET;
        serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
        serv_addr.sin_port = htons(atoi(argv[1]));

        /* 소켓에 주소 할당 */
        if(bind(serv_sock, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) == -1)
                error_handling("bind() error");

        /* 연결 요청 대기 상태로 진입 */
        if(listen(serv_sock, 5) == -1)
                error_handling("listen() error");

        clnt_addr_size = sizeof(clnt_addr);
        /* 연결 요청 수락 */
        clnt_sock = accept(serv_sock, (struct sockaddr*) &clnt_addr, &clnt_addr_size);

        if(clnt_sock == -1)
                error_handling("accept() error");

        /* 데이터 전송 */
        write(clnt_sock, message, sizeof(message));
        /* 연결 종료 */
        close(clnt_sock);

        return 0;
}

void error_handling(char *message)
{
        fputs(message, stderr);
        fputc('\n', stderr);
        exit(1);
}


Client.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>

void error_handling(char *message);

int main(int argc, char **argv)
{
        int sock;
        struct sockaddr_in serv_addr;
        char message[30];
        int str_len;

        if(argc != 3)
        {
                printf("Usage : %s <IP> <port>\n", argv[0]);
                exit(1);
        }

        /* 서버 접속을 위한 소켓 생성 */
        sock = socket(PF_INET, SOCK_STREAM, 0);

        if(sock == -1)
                error_handling("socket() error");

        memset(&serv_addr, 0, sizeof(serv_addr));

        serv_addr.sin_family = AF_INET;
        serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
        serv_addr.sin_port = htons(atoi(argv[2]));

        /* 서버로 연결 요청 */
        if(connect(sock, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) == -1)
                error_handling("connect() error");

        /* 데이터 수신 */
        str_len = read(sock, message, sizeof(message)-1);

        if(str_len == -1)
                error_handling("read() error");
        message[str_len] = 0;

        printf("Message from server: %s\n", message);
        /* 연결 종료 */
        close(sock);

        return 0;
}

void error_handling(char *message)
{
        fputs(message, stderr);
        fputc('\n', stderr);
        exit(1);
}


출처 :

http://sp0ngee.tistory.com

posted by stluck
2012. 4. 22. 14:47 Tools/Linux

ARP spoofing을 이용하여 로컬 네트워크 상에서 MAC address 조작이 가능하다는 것은 많은 분들이 알고 계시겠지만, 로컬 머신 자체의 MAC address도 수정이 가능하다는 것은 모르시는 분들이 계실 것 같아 알려드립니다. 저도 오늘 MAC address 관련 내용을 검색하던 중 처음 알게된 내용입니다. 

윈도우 및 리눅스 모두 로컬 MAC address 변경이 가능합니다(관리자 권한 로그인 후).

로컬 MAC address 변경은 MAC address에 네트워킹 제약이 가해져 있거나, 소프트웨어 인증용으로 MAC address가 사용될 경우를 우회하는 용도로 사용될 수 있습니다.

아래는 OS별로 방법이 잘 요약된 http://www.irongeek.com/i.php?page=security/changemac에서 발췌한 내용입니다. 윈도우 2003에서 Method1(아래참조)을 테스트 해보았는데, MAC address를 바꾸어도 네트워킹에 전혀 문제가 없었습니다(리부팅하지 않아도 바로 적용됨).

 BSD
1) Bring down the interface: "ifconfig xl0 down"
2) Enter new MAC address: "ifconfig xl0 link 00:00:00:AA:AA:AA"
3) Bring up the interface: "ifconfig xl0 up"

Linux
1) Bring down the interface: "ifconfig eth0 down"
2) Enter new MAC address: "ifconfig eth0 hw ether 00:00:00:AA:AA:AA"
3) Bring up the interface: "ifconfig eth0 up"

Windows 2000/XP
Method 1:
This is depending on the type of Network Interface Card (NIC) you have. If you have a card that doesn’t support Clone MAC address, then you have to go to second method.
a) Go to Start->Settings->Control Panel and double click on Network and Dial-up Connections.
b) Right click on the NIC you want to change the MAC address and click on properties.
c) Under "General" tab, click on the "Configure" button
d) Click on "Advanced" tab
e) Under "Property section", you should see an item called "Network Address" or "Locally Administered Address", click on it.
f) On the right side, under "Value", type in the New MAC address you want to assign to your NIC. Usually this value is entered without the "-" between the MAC address numbers.
g) Goto command prompt and type in "ipconfig /all" or "net config rdr" to verify the changes. If the changes are not materialized, then use the second method.
h) If successful, reboot your system.

Method 2:
This should work on all Windows 2000/XP systems
a) Go to Start -> Run, type "regedt32" to start registry editor. Do not use "Regedit".
b) Go to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}". Double click on it to expand the tree. The subkeys are 4-digit numbers, which represent particular network adapters. You should see it starts with 0000, then 0001, 0002, 0003 and so on.
c) Find the interface you want by searching for the proper "DriverDesc" key.
d) Edit, or add, the string key "NetworkAddress" (has the data type "REG_SZ") to contain the new MAC address.
e) Disable then re-enable the network interface that you changed (or reboot the system).

Method 3:
Use the program Etherchange from http://ntsecurity.nu/toolbox/etherchange/
Windows 9x
Use the same method as Windows 2000/XP except for the registry key location is "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Net" and you must reboot your system.

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

http://en.wikipedia.org/wiki/MAC_address var viewer_image_url = "http://blogimgs.naver.com/blog20/blog/layout_photo/viewer/"; var photo = new PhotoLayer(parent.parent.parent); photo.Initialized(); window.onunload = function() { photo.oPhotoFrame.doFrameMainClose(); }.bind(this);

어디선가 가져왔는데... 어디지?

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

일단 맥을 변경 하는 방법에 대해 알아보자.


1. 바탕화면에서 "내 네트워크 환경"에 오른쪽 클릭을 해서 "속성"을 선택하면 "네트워크 연결"이 뜬다.

2. 랜카드 속성을 연다.

3. 랜카드 이름이 있고 그 옆의 "구성"을 클릭한다.

4. "고급"을 클릭한다.

5. "네트워크 주소" 나 "Network Address" 가 있을것이다 그것을 선택한다.

6. 값에 새로운 맥 어드레스를 입력한다.

7. 확인을 누르면 맥 어드레스가 바뀌어 있을 것이다.


그런데 5번에서 막히는 사람이 있을 것이다. "네트워크 주소"나 "Network Address"가 없는 경우이다.

어떻게 할 것인가?

방법은 간단하다. 레지스트리를 조금만 추가해 주면 된다.


이제 레지스트리를 추가해 보자.

01. "regedit"를 실행한다.

02. [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}]로 간다.

03. 숫자로된 키들이 있다.(001, 002... 이런식임)

04. 그중에 자신의 랜카드를 찾아야 한다.

05. 찾았으면 "랜카드번호\Ndi\params"로 간다.

06. "NetworkAddress"라는 이름으로 키를 생성한다.

07. 이제 "NetworkAddress" 안에 6가지의 문자열 값을 만들면 된다.

08. "Default"를 만든다. 값은 넣지 않는다.

09. "ParamDesc"를 만든다. 값은 "Network Address" 또는 "네트워크 주소"라고 넣는다.

10. "Type"을 만든다. 값은 "edit"라고 넣는다.

11. "LimitText"를 만든다. 값은 "12"라고 넣는다.

12. "Optional"을 만든다. 값은 "1"이라고 넣는다.

13. "UpperCase"를 만든다. 값은 "1"이라고 넣는다.


이제 레지스트리 추가가 끝났다. 다시 맥을 변경해 보자. 이제는 맥을 내맘대로 변경 할 수 있다.

테스트는 XP에서만 해봤기 때문에 다른 OS에서 동작은 보장 할 수 없다.


내 컴퓨터에 테스트한 레지스트리 값

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

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0015\Ndi\params\NetworkAddress]
"Default"=""
"ParamDesc"="Network Address"
"Type"="edit"
"LimitText"="12"
"Optional"="1"
"UpperCase"="1"

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


posted by stluck
2011. 12. 28. 00:56 건강/Cat.1

정사(正邪)가 밖으로부터 체내에 침입하면 일정한 부위에 머물지 않고 오장에 넘쳐흐르면서 자리를 잡지 못하고 영기 위기와 함께 운행하며 혼백과 함께 떠돌므로 사람으로 하여금 편안히 잠들지 못하고 꿈만 꾸게 합니다.

사기가 육부에 침입하면 외부에서는 남게 되고 내부에서는 부족하게 됩니다.

반면에 사기가 오장에 침입하면 내부에서는 남게 되고 외부에서는 부족하게 됩니다.

그래서 음기(陰氣)가 성하면 큰 강을 건너가면서 두려워하는 꿈을 꾸고,

양기(陽氣)가 성하면 꿈에 큰 불이 보여서 뜨거운 감을 느끼며,

음양이 모두 성하면 서로 죽이는 꿈을 꿉니다.

상부가 성하면 날아가는 꿈을 꾸고,

하부가 성하면 떨어지는 꿈을 꾸며,

몹시 굶주리면 음식을 섭취하는 꿈을 꾸고,

지나치게 과식하면 주는 꿈을 꾸며,

간기(肝氣)가 성하면 성내는 꿈을 꾸고,

폐기(肺氣)가 성하면 두려워하고 울며 날아가는 꿈을 꾸며,

심기(心氣)가 성하면 잘 웃거나 무서워하고 두려워하는 꿈을 꾸고,

비기(脾氣)가 성하면 노래부르면서 즐거워하거나 몸이 무거워 움직이지 못하는 꿈을 꾸며, 신기(腎氣)가 성하면 허리와 척추가 둘로 갈라져 연결되지 않는 꿈을 꿉니다.

이 12가지 사기가 성한 경우는 사기가 있는 부위를 파악한 다음 사법을 쓰면 곧 낫습니다.

궐기가 심(心)에 침입하면 언덕에 불이 나는 꿈을 꾸고

폐(肺)에 침입하면 날아오르거나 금철과 같은 기괴한 물건들이 보이는 꿈을 꾸며

간(肝)에 침입하면 수림 속의 나무가 보이는 꿈을 꾸고

비(脾)에 침입하면 구릉이나 큰 못 허물어진 집과 비바람이 보이는 꿈을 꾸며

신(腎)에 침입하면 못가에 가서 물에 빠지는 꿈을 꾸고

방광(膀胱)에 침입하면 여행하는 꿈을 꾸며

위(胃)에 침입하면 음식물이 보이고

대장(大腸)에 침입하면 꿈에 들판이 나타나며

소장(小腸)에 침입하면 꿈에 사람들이 모이는 교통의 요충지가 보입니다.

담(膽)에 침입하면 서로 다투고 송사하며 배를 갈라 자살하는 꿈을 꾸고

음기(陰器)에 침입하면 성교하는 꿈을 꾸며

목에 침입하면 목이 잘리는 꿈을 꿉니다.

정강이에 침입하면 걷거나 달리려고 해도 앞으로 나갈 수 없고 깊은 땅굴에서 자는 꿈을 꾸고

넓적다리와 위팔에 침입하면 꿈에 무릎을 꿇고 인사하며

포(胞)와 직장(直腸)에 침입하면 꿈에 대소변을 봅니다.

이 15가지 정기가 부족한 경우는 사기가 있는 부위를 파악한 다음 보법을 쓰면 곧 낫습니다.


출처 : 진성한의원 ( http://jinsungomd.com  )

'건강 > Cat.1' 카테고리의 다른 글

운동기구 대여 - 대전  (0) 2013.10.19
posted by stluck