반응형

// http://sourceforge.net/projects/wakeonlan/
// WakeOnLan - commandline application to start computers via wake on lan enbaled
// network interface card.
// Author: erik.tornstam@home.se
// Copyright: erik.tornstam@home.se

#include "stdio.h"
#include "iostream.h"
#include "winsock2.h"

#define DEFAULT_BROADCAST "255.255.255.255"
#define DEFAULT_PORT 32767

parse_mac(unsigned char *mac, char *str)
{
    int i;
    int count;
    char c;
    unsigned char val;
    int separator_ok = 1;

    for (i = 0; i < 6; i++) {
  mac[i] = 0;
    }

    for (i = 0; i < 6; i++) {
  count = 0;
  val   = 0;
  do {
   c = toupper(*str++);
   if (c >= '0' && c <= '9')
   {
    val = (val * 16) + (c - '0');
   }
   else if (c >= 'A' && c <= 'F')
   {
    val = (val * 16) + (c - 'A') + 10;
   }
   else if (c == '-' || c == ':')
   {
   if (separator_ok || count-- != 0)
    break;
   }
   else if (c == '\0')
   {
    str--;
    break;
   }
   else
   {
    return 0;
   }
   separator_ok=1;
  } while (++count < 2);

  separator_ok=(count<2);
  *mac++ = val;
    }

    if (*str)
  return 0;

    return 1;
}

int wakeup(char * sMacAddr, char * sBroadcast, int iPort)
{
 WSADATA wsaData;
 int   s;
 struct sockaddr_in bcast;
 char msg[1024];
    int  msglen = 0;
 unsigned char macaddr[6];

 if (! parse_mac(macaddr, sMacAddr) )
 {
  cerr << "Illegal MAC address" << endl;
  return -1;
    }

 for (int i = 0; i < 6; i++) {
  msg[msglen++] = (char)0xff;
    }

    for (i = 0; i < 16; i++) {
  for (int j = 0; j < sizeof(macaddr); j++) {
   msg[msglen++] = macaddr[j];
  }
    }

 if (!WSAStartup(MAKEWORD(1, 1), &wsaData))
 {
  if ((s = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET)
  { 
   memset((char *)&bcast,0,sizeof(bcast));
   bcast.sin_family=AF_INET;
   bcast.sin_addr.s_addr=inet_addr(sBroadcast);
   bcast.sin_port=htons(iPort);

   if ( connect(s,(struct sockaddr *)&bcast,16)== -1)
   {
    cerr << "Cannot connect socket" << endl;
    return -2;
   }

   sendto(s, (const char *)&msg, msglen, 0, (struct sockaddr *)&bcast, sizeof(bcast));
   closesocket(s);
  }
  else
  {
   cerr << "Error getting socket" << endl;
  }

  WSACleanup();
  return(0);
 }
 else
  return -3;
}

void printHelp(char * argv[])
{
 cout << "WakeOnLan (c) erik.tornstam@home.se" << endl;
 cout << "Sends a WakeOnLan packet to a network." << endl << endl;
 cout << "Usage: " << argv[0] << " -a macaddress [-b broadcast address] [-p port] " << endl << endl;
 cout << "\t-a\tMAC-address of NIC to wake.  (00-04-00-c8-85-2d)" << endl;
 cout << "\t-b\tBroadcast address, default address is " << DEFAULT_BROADCAST << endl;
 cout << "\t-p\tPort number, default port is " << DEFAULT_PORT << endl;
}

int main(int argc, char* argv[])
{
 char macaddress[20] = "";
 char broadcast[20] = DEFAULT_BROADCAST;
 int port = DEFAULT_PORT;
 int argcnt=0;

 for(int c=1; c
 {
  if(stricmp("-a",argv[c])==0 && (argc > c+1) && argv[c+1][0]!='-')
  {
   strcpy(macaddress,argv[c+1]);
   argcnt++;
  }
  if(stricmp("-b",argv[c])==0 && (argc > c+1) && argv[c+1][0]!='-')
  {
   strcpy(broadcast,argv[c+1]);
   argcnt++;
  }
  if(stricmp("-p",argv[c])==0 && (argc > c+1) && argv[c+1][0]!='-')
  {
   port=atoi(argv[c+1]);
   argcnt++;
  }
 }

 if(argcnt < 1 || strcmp(macaddress,"")==0)
 {
  printHelp(argv);
  return -1;
 }
 cout << "Wakeupcall to " << macaddress << " broadcast over " << broadcast << " on port " << port << endl;
 wakeup(macaddress, broadcast, port);

 return 0;
}

출처 : http://visitagain.tistory.com/tag/WOL
VS2005 C++로 컴파일 해봤음, 오류남. ..

'Programming' 카테고리의 다른 글

11월 17일 랩실 C언어 교육  (0) 2009.11.17
WOL c++ 다른 소스코드  (0) 2009.10.29
IE8설치 후 VS에러 패치  (0) 2009.10.14
컴포넌트의 종류  (0) 2009.08.28
Flex Builder 3  (0) 2009.08.28
반응형

Magic Packet
I'm not sure, but it seems that the name comes from AMD. I did not do a search but Jos� Pedro Oliveira (second link above) says that there is more documentation about the protocol in their web site. As I mentioned above, you need to send a special packet in your LAN network, so that the remote computer will receive it and wake up. This so-called Magic packet consists of the following parts:

1.6 Bytes Header which is nothing but 6 bytes of 0xff.
2.16*6 Bytes Data. To produce data you'll need to repeat remote computers MAC (Media Access Control) Address 16 times. Look at the below figure:
 

Magic Packet(With Secure On Password)
(This part added on an update on: 2005/09/03. Note that 'PowerOn' sample has been updated in all downloads either. [as well as executables!])

Some clients require a password in the packet to be turned on, otherwise they simply won't! This password is also known as SecureOn, and will be attached at the end of the packet. In this case, a packet will look something like this:

 

So we have six cells, each capable of saving an integer number between 0 and 255(Just like MAC bytes).

'Network' 카테고리의 다른 글

전세계 공개 FTP 서버 리스트  (0) 2009.11.21
매직패킷 정리  (0) 2009.11.07
paros 3.2.13 - 웹 취약점 분석툴  (0) 2009.08.07
패킷 캡쳐 및 분석 - Wireshark  (0) 2009.07.09
proxy 유틸리티 - Burp Suit 1.2  (0) 2009.07.09
반응형

http://able.kbs.co.kr/live/index.html

에 가셔서 보고싶은 채널 선택하셔서 보시면 됩니다.

'Web' 카테고리의 다른 글

구글 애드센스 약관 및 정책  (0) 2009.12.17
웹분석 도구의 분류  (0) 2009.12.15
HTTP Debugger Pro v3.4 - 웹 분석 툴  (0) 2009.08.16
Google Dork part 1, 2  (0) 2009.08.07
Web 2.0  (0) 2009.08.07
반응형
IE8 설치후 VisualStudio에서 Visual C++ 스마트장치 프로젝트 생성시 "프로젝트를 만들지 못했습니다."라는 에러와 함께 프로젝트 생성에 실패하는 경우 이렇게 해결한다.

1. 레지스트 편집기를 연다.
2. "HKEY_CURRENT_USER\Software\Microsoft]Windows\InternetSettings\Zones" 로 이동한다.
3. 해당 경로의 하위에 "1000"이름의 키를 생성한다.
4. 생선된 키에 "1207"이름의 DWORD값을 생성, 값은 기본값인 "0"으로 한다.
5. VisualStudio를 재 실행하여 정상 동작 여부를 확인한다.

참고글 : http://blogs.msdn.com/vcblog/archive/2009/03/28/some-vs2005-and-vs2008-wizards-pop-up-script-error.aspx

'Programming' 카테고리의 다른 글

WOL c++ 다른 소스코드  (0) 2009.10.29
WOL c++ sourcecode  (0) 2009.10.29
컴포넌트의 종류  (0) 2009.08.28
Flex Builder 3  (0) 2009.08.28
직각삼각형 출력  (0) 2009.08.12
반응형

rm -r 디렉토리  
요건 메세지가 매번 뜸

rm -rf 디렉토리
요건 메세지 안뜨고 지움
반응형
비주얼 컴포넌트(Visual Component)
  • 컨트롤 컴포넌트
  • 레이아웃 컨테이너 컴포넌트
  • 네비게이터 컴포넌트
  • 커스텀 컴포넌트
  • 차트 컴포넌트


넌비주얼 컴포넌트(Non-visual Component)
  • <mx:Script>
  • <mx:Model>
  • <mx:XML>
  • <mx:Array>

'Programming' 카테고리의 다른 글

WOL c++ sourcecode  (0) 2009.10.29
IE8설치 후 VS에러 패치  (0) 2009.10.14
Flex Builder 3  (0) 2009.08.28
직각삼각형 출력  (0) 2009.08.12
FLEX + 네이버 API 연동 예제  (0) 2009.08.09

+ Recent posts