Sunday, February 27, 2011

C++ to HTML

Sometimes, if you would show your C++ source code in a certain web site(e.g. blog), you'd better convert C++ source code into HTML format. Here is a good web site for this.

http://www.bedaux.net/cpp2html

The differences among auto_ptr, scoped_ptr and shared_ptr



#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <memory>
#include <stdio.h>

#include "Int.h" // include 4 bytes int class

typedef std::auto_ptr<Int>     auto_ptr;
typedef boost::scoped_ptr<Int> scoped_ptr;
typedef boost::shared_ptr<Int> shared_ptr;

void size()
{
  printf("sizeof(auto_ptr)   is %d\n", sizeof(auto_ptr));   // 4
  printf("sizeof(scoped_ptr) is %d\n", sizeof(scoped_ptr)); // 4
  printf("sizeof(shared_ptr) is %d\n", sizeof(shared_ptr)); // 8
}

void foo_ptr(auto_ptr ap)
{
  ap->foo();
}

void foo_ptr(scoped_ptr scp)
{
  scp->foo();
}

void foo_ptr(shared_ptr shp)
{
  shp->foo();
}

void foo()
{
  {
    //
    // auto_ptr
    //
    Int* pi = new Int(5);
    auto_ptr ap(pi);

    foo_ptr(ap);     // compile ok
    ap->foo();       // runtime error
  }

  {
    //
    // scoped_ptr
    //
    Int* pi = new Int(5);
    scoped_ptr scp(pi);

    // foo_ptr(scp); // compile error
    scp->foo();      // runtime ok
  }

  {
    //
    // scoped_ptr
    //
    Int* pi = new Int(5);
    shared_ptr shp(pi);
foo_ptr(shp);    // compile ok
    shp->foo();      // runtime ok
  }
}

int main()
{
  size();
  foo();
}

Download source code : http://sites.google.com/site/gilgildownload/download/IntTest2.zip

C++ copy constructor and assign operator



Can you distinguish between copy constructor and assign operator in C++ code? Here's a sample for you. Be aware of knowing that even if it's code format looks assign operator format, it is not assign operator format but copy constructor one.


Download source code : https://sites.google.com/site/gilgildownload/download/IntTest.zip


class Int
{
public:
  // constructor
  Int(const int i = 0)                 { printf("C...
  Int(const Int& r)                    { printf("C...


  // destructor
  virtual ~Int()                       { printf("D...


  // assign operator
  const Int& operator = (const int i)  { printf("A...
  const Int& operator = (const Int& r) { printf("A...
};


void foo()
{
  {
    Int a(1);  // C
    Int b(2);  // C
    Int c(a);  // C
  }


  {
    Int a(3);  // C
    Int b;     // C
    b = 4;     // A
    Int c;     // C
    c = a;     // A
  }


  {
    Int a(5);  // C
    Int b = 6; // C // not assign operator
    Int c = a; // C // not assign operator
  }
}


int main()
{
  foo();
}

Wednesday, February 23, 2011

Highscore - The Boost C++ Libraries

There are so many articles and exmaples for boost.



How to build boost library as release & static & multi thread & static runtime library in visual studio

In boost directory, type the followng command.

bjam variant=release link=static threading=multi address-model=32 runtime-link=static

It may take a few minutes to build libraries, and you will get "*-mt-s-*.lib" files in library directory($root/stage/lib).

Form example,
2011-02-23 오후 11:53 720,852 libboost_date_time-vc80-mt-s-1_45.lib
2011-02-23 오후 11:54 1,893,972 libboost_filesystem-vc80-mt-s-1_45.lib
2011-02-23 오후 11:55 5,675,002 libboost_graph-vc80-mt-s-1_45.lib
2011-02-23 오후 11:48 423,886 libboost_iostreams-vc80-mt-s-1_45.lib
2011-02-23 오후 11:50 1,550,020 libboost_math_c99-vc80-mt-s-1_45.lib
2011-02-23 오후 11:50 1,570,926 libboost_math_c99f-vc80-mt-s-1_45.lib
2011-02-23 오후 11:50 1,538,966 libboost_math_c99l-vc80-mt-s-1_45.lib
2011-02-23 오후 11:49 5,769,460 libboost_math_tr1-vc80-mt-s-1_45.lib
2011-02-23 오후 11:49 5,905,880 libboost_math_tr1f-vc80-mt-s-1_45.lib
2011-02-23 오후 11:49 5,706,556 libboost_math_tr1l-vc80-mt-s-1_45.lib
2011-02-23 오후 11:51 320,242 libboost_prg_exec_monitor-vc80-mt-s-1_45.lib
2011-02-23 오후 11:50 5,050,400 libboost_program_options-vc80-mt-s-1_45.lib
2011-02-23 오후 11:50 108,922 libboost_random-vc80-mt-s-1_45.lib
2011-02-23 오후 11:54 10,374,684 libboost_regex-vc80-mt-s-1_45.lib
2011-02-23 오후 11:51 11,429,740 libboost_serialization-vc80-mt-s-1_45.lib
2011-02-23 오후 11:51 926,442 libboost_signals-vc80-mt-s-1_45.lib
2011-02-23 오후 11:53 92,208 libboost_system-vc80-mt-s-1_45.lib
2011-02-23 오후 11:52 10,232,224 libboost_test_exec_monitor-vc80-mt-s-1_45.lib
2011-02-23 오후 11:52 464,268 libboost_thread-vc80-mt-s-1_45.lib
2011-02-23 오후 11:52 11,447,096 libboost_unit_test_framework-vc80-mt-s-1_45.lib
2011-02-23 오후 11:53 46,877,338 libboost_wave-vc80-mt-s-1_45.lib
2011-02-23 오후 11:51 9,099,918 libboost_wserialization-vc80-mt-s-1_45.lib

Friday, December 7, 2007

[POC2007] 내 메신저 대화내용 누군가 보고 있다!

스푸핑과 MITM·VR 등과 결합, 신개념 스니핑 기법 공개...'GilGil' 이번 ‘POC2007’(http://www.powerofcommunity.net/)에서 발표자 'GilGil'은 SnoopSpy2를 통해 보안서버 상에서 패스워드 스니핑, SSH 클라이언트 상의 데이터 스니핑, MSN 메신저와 같은 국내에서 많이 사용되는 주요 메신저의 대화 스니핑, VoIP 스니핑, FPS 게임 해킹 등을 현장에서 직접 보여줄 것이다. 그동안 국내에서 추진되어온 보안 서버에 보안 문제가 여전히 존재하고 있으며 보안서버만으로는 완벽한 보안이 이루어지지 않는다는 것을 확인할 수 있을 것이다. 다음은 그와의 인터뷰 내용이다.

Interview 발표자: ‘GilGil’
이번 발표내용에 대해 좀 더 구체적으로 설명해준다면?
지금까지 대두되고 공개되어져 왔던 스니핑 기반의 해킹 기법들을 총망라해보는 것입니다. 처음에는 단순히 패킷을 보는 것으로 시작한 스니핑 기법이 점차 스푸핑(Spoofing), MITM(Man In The Middle Attack) 및 VR(Version Rollback) 등과 결합하여 새로운 스니핑의 해킹 기법으로 진화하고 있습니다. 이러한 다양한 스니핑 기법에 대해 정리를 하고 발표를 해보고자 합니다.

이를 악용하면 어떤 문제점들이 발생할 수 있나?
해커의 입장에서 봤을 때에 노력의 차이, 시간의 차이가 있기는 하지만 메신저 대화, 인터넷 전화 통화, 각종 개인 신상 정보 등 인터넷 프로토콜(IP) 기반의 모든 통신 정보들이 노출될 수 있습니다. 이러한 스니핑 기반의 정보 누출을 막기 위해 훌륭한 암호화 정책이 수립되어 실천이 되고 있지만 그런 것들이 영원한 방패막이 될 수는 없습니다. 해킹은 보안보다 항상 앞서 나아가기 때문입니다.

메신저 서비스 기업에 한마디 하신다면?
해커는 그럴만한 가치가 있는 것에만 해킹을 시도한다는 불문율이 있습니다. 관심이 없다면 해킹을 하지도 않습니다. 자사 제품에 대한 취약점이 공개된 것을 부정적인 면으로만 보지 말았으면 좋겠으며 공개된 취약점때문에 해야 할 일이 하나 더 늘어 났다라고만 하는 불평보다는 같이 해결해나갈 수 있는 공감대를 형성해나갈 수 있는 여유로움과 관대함을 가질 수 있었으면 하는 바람입니다.

메신저를 이용하는 이용자들이 주의해야 할 점이 있다면?
해킹차원의 기술적인 입장뿐 아니라 기업차원의 법적인 입장을 고려해서도 메신저를 통해 오고 가는 모든 내용들은 제 3자에 의해 노출될 수 있고 저장될 수 있으며 실제로 관련 제품들도 나와 있습니다. 회사의 기밀보호의 차원으로 봤을 때에는 관련 제품들을 오히려 긍정적으로도 볼 수 있습니다. 사용자의 입장에서는 이러한 사실을 항상 인지하고 정말 중요한 내용에 대해서는 가급적 메신저를 사용하지 않도록 하는 마인드가 중요합니다.

이번 POC2007 컨퍼런스에 거는 기대가 있다면?
해커나 정호보호 전문가들에 의해 여러 방면의 취약점들이 발견되어져 오고 있지만 대부분 금단의 열매로 치부가 되어 공론화되지 못하는 것이 일반적입니다. 취약점 공개가 금기시될 수밖에 없기 때문에 보안 실무자나 관련 담당자는 그러한 문제점들을 이론적으로만 접근할 수밖에 없으며 문제점의 본질적인 곳을 접하지 못하기 때문에 그에 따르는 올바른 보안정책을 수립할 수가 없습니다.

이러한 원인과 결과로 인해 보안정책 수립이 제대로 되지 않으면서 점점 더 취약해 질 수 밖에 없는 악순환의 고리만 반복됩니다. 만약 그러한 취약점의 정보들이 공론화될 수 있는 문화가 형성된다면 처음 설계나 개발단계에서부터 한층 더 안정적인 서비스가 가능하게 되고 보안적인 면에서 한층 더 발전할 수 있을 것이라는 긍정적인 판단을 해 봅니다. POC2007은 이러한 면에 있어서 더욱 실무적이고 현실적인 정보공유의 자리로 거듭났으면 하는 바람입니다.

[길민권 기자(reporter21@boannews.com)]