Open Source/BackTrack

[BackTrack5 R3] URLCrazy

DarkSoul.Story 2013. 2. 4. 15:06
반응형



개요


URLCrazy는 확인하고자 하는 도메인에 대해서 오타 및 비슷한 도메인으로 불법으로 점유하는 도메인이 존재하는지 검사하는 도구 입니다. 오타 및 비슷한 도메인으로 불법으로 점유하는 도메인의 경우 피싱, URL 하이재킹 등에 이용되는 경우가 많이 존재합니다. 

 

URLCrazy의 특징을 살펴 보면 다음과 같습니다.

- 15 종류의 도메인 변종 생성

일반적인 맞춤법 틀린 단어를 8000개 이상 탑재하고있음

- 멀티 키보드 레이아웃 (Multiple keyboard layouts :qwerty, azerty, qwertz, dvorak) 지원 

   -> 키보드를 누르면서 오타가 가장 많이 나는 부분

- 확인하고자 하는 도메인을 기준으로 변형된 도메인 존재 유무 체크 (IP가 할당되어있는지 체크)

 Ruby interpreter 필요

- Supports cosmic ray induced bit flipping 지원 

 

테스트 환경 

 운영 체제 (OS) : BackTrack5 R3


 

상세 분석



옵션

 

-k, --keyboard=LAYOUT: 키보드 배열 지정 (qwerty, azerty, qwertz ,dvorak 기본값 : qwerty)

-p, --popularity        : Google을 이용하여인기 있는 도메인 체크

-r, --no-resolve        : DNS Resolve 하지 않음(DNS 쿼리를 보내지 않음)

-i, --show-invalid     : 잘못된 도메인 이름 표시 (도메인이 존재할 경우 : true 아닌경우 : false)

-f, --format=TYPE     : 출력 포맷 지정

                               (사람이 읽을 수 있는 문자 또는 CSV  기본값 : 사람이 읽을 수 있는 문자)

-o, --output=FILE      : 결과 값 파일로 저장

-h, --help                : Help

-v, --version           : 현재 버전 출력


URLCrazy를 실행하면, 입력한 도메인과 지정한 키보드 레이아웃을 대입하여 임의의 도메인을 자동으로 만들어 낸다. 자동으로 만들어낸 도메인 이름들을 바로 출력해 준다.


의 그림은 urlcrazy를 실행한 결과 이다. 하나하나 살펴 보도록 하자

 

제일 먼저 살펴볼 것은 Typo Type 입니다. Typo Type는 자동으로 생성된 도메인에 대해서 어떤 형식으로 만들었는지를 알려주며 형식은 아래와 같다.

 

Typo Type

               

Character Omission

문자 누락 : 입력한 도메인에서 문자 1개씩 빠진 형태

            ex) www.example.com -> ww.example.com

Character Repeat

문자 반복 : 입력한 도메인에서 같은 문자 1개씩 더 입력한 형태

            ex) www.example.com -> ww.eexample.com

Character Swap

문자 자리 이동 : 입력한 도메인에서 1개의 문자 자리가 바뀐 형태

            ex) www.example.com -> www.xeample.com

Character Replacement

문자 대체 : 입력한 도메인에서 1개의 문자를 변경한 형태

ex) www.example.com -> wwq.example.com

Character Insertion

문자 삽입 : 입력한 도메인에서 1개의 문자가 더 입력된 형태

            ex) www.example.com -> wwqw.example.com

Double Character Replacement

더블 문자 대체 : 입력한 도메인에서 2개의 문자를 변경한 형태

ex) www.example.com -> wwq.egample.com

Missing Dot

입력한 도메인에서 www를 한번 더 입력한 형태

 ex) www.example.com -> wwwwww.example.com

Wrong TLD

최상위 도메인

Bit Flipping

 

 

다음으로 살펴 볼 영역은 DNS-A 영역 입니다. DNS-A 영역은 자동으로 생성된 도메인 이름으로 DNS 쿼리를 날려 DNS 응답을 받을 경우 해당 IP를 표시 한다. 또한 DNS-MX은 자동으로 생성된 도메인이 사용하는 DNS MX레코드 (메일)를 표시 한다. 만약 자동으로 생성된 도메인에 대한 DNS 응답이 없는 경우 해당 영역에는 아무것도 표시가 되지 않는다.



다음은 CC-A 영역 입니다. CC-A 영역은 DNS-A 영역에서 표시된 IP의 국가 코드를 표시한다. 국가 코드를 표시하는 방법은 같은 폴더 안에 존재하는 country.rb를 이용한다.

 

def Countrylookup.startup

# ok, set up @rfile. open once.

        folder=File.expand_path(File.dirname(__FILE__))

        country_db = folder + "/country-ips.dat"

 

        if File.exists?(country_db)

                @rfile=File.open(country_db,"rb")

        else

                if File.exists?(folder + "/IpToCountry.csv")

                # pack that file & do it once

                        last_start=nil

                        last_end=nil

                        last_country=nil

                        File.open(folder + "/country-ips.dat","wb"do |wfile|

                                IO.foreach(folder + "/IpToCountry.csv"do |line|

          next if line[0..0] =="#"

                                        next if !(line =~ /^"/ )

                                        s,e,d1,d2,co=line.delete!("\"").split(",")

                                        s,e = s.to_i,e.to_i

                                        if !last_start

                                                # initialize with first entry

                                                last_start,last_end,last_country = s,e,co

                                        else

                                                if s==last_end+1 and co==last_country

                                                        # squeeze if successive ranges have zero gap

                                                        last_end=e

                                                else

                                                        # append last entry, remember new one

                                                        wfile << [last_start,last_end,last_country].pack("NNa2")

                                                        last_start,last_end,last_country = s,e,co

                                                end

                                        end

                                end

                                # print last entry

                                if last_start

                                        wfile << [last_start,last_end,last_country].pack("NNa2")

                                end

 

                                       end

                                end

                                # print last entry

                                if last_start

                                        wfile << [last_start,last_end,last_country].pack("NNa2")

                                end

                        end

                        # open the DB now

                        @rfile=File.open(country_db,"rb")

                else

      raise "Aborting: Cannot find country database."

    end

        end

 

        f = folder + "/country-codes.txt"

        @ccnames={};

        File.open(f,"r:UTF-8").readlines.each do |line|

                x=line.split(",");

                @ccnames[x[1]] = x[0]

        end

end

 

 

def Countrylookup.ip2cc(ip)

  found=[]

 

  if @rfile and ip and ip =~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/

          @rfile.seek(0,IO::SEEK_END)

          record_max=@rfile.pos/10-1

 # build a 4-char string representation of IP address

            # in network byte order so it can be a string compare below

            ipstr= ip.split(".").map {|x| x.to_i.chr}.join

 

            # low/high water marks initialized

            low,high=0,record_max

            while true

              mid=(low+high)/2       # binary search median

              @rfile.seek(10*mid)     # one record is 10 byte, seek to position

              str=@rfile.read(8)      # for range matching, we need only 8 bytes

              # at comparison, values are big endian, i.e. packed("N")

              if ipstr>=str[0,4]     # is this IP not below the current range?

                if ipstr<=str[4,4]   # is this IP not above the current range?

                  #puts  # a perfect match, voila!

                  cc=@rfile.read(2)

      found =[cc,@ccnames[cc]]

                  break

                else

                  low=mid+1          # binary search: raise lower limit

                end

              else

                high=mid-1           # binary search: reduce upper limit

              end

              if low>high            # no entries left? nothing found          

                #m << {:string=>"No country"}  

                break

              end

            end

  end

found

end

 

end



참고 URL 및 도서

http://www.morningstarsecurity.com/research/urlcrazy

반응형