2013년 12월 3일 화요일

왓챠 (Watcha) api 분석


왓챠는 유저의 평가를 바탕으로 영화를 추천해주는 웹 서비스다.

왓챠를 분석하게 된 이유는 유한개의 DB를 가지고 있는 서비스에서

모든 영화를 평가했을때 어떻게 될까 라는 단순한 호기심이 생겼었기 때문이다.

사실 웹 사이트 api 분석이라기 보다는 json 둘러보기 정도가 더 정확한듯 하다.


MySQL을 사용하고는 있으나 웹 프레임 워크(루비온레일즈)를 사용하고 있기 때문에 sql injection를 기대하진 않았다.

또한 왓챠의 멤버 중에서 보안 실력이 뛰어난 분이 계시기 때문에 큰 문제는 없을거란걸 알았다.


가장 핵심인 '영화 추천' 부분은 무한 스크롤 기능을 통해 서버에 request를

http://watcha.net/api/movies/recommend?ref=wall&count=8&more=true

와 같은 주소로 전송하고 json 형태로 받아오게 된다.



count를 증가시키면 데이터를 더 받아올 수는 있지만 위의 request로는 20개가 최대인것 같다.

하지만

http://watcha.net/api/movies?type=eval&count=900&more=true&page=

와 같은 형태로 request를 보내면 900개의 데이터를 볼 수 있었다.




그리고 구글링을 통해서

http://watcha.net/movies/detail/18681‎

와 같은 형태로 영화 정보를 얻을 수 있다는 사실을 알 수 있었다.

이를 통해 watcha에 저장된 모든 영화의 id와 hash된 id를 얻을 수 있었다.


다행이도 지금은 위의 url이 막힌것처럼 보이며,

http://watcha.net/api/movie/mp0dx6

와 같이 숫자가 아닌 hash화된 id를 통해서 영화 정보를 얻어온다.


그리고 비슷한 영화를 추천할 때는

http://watcha.net/api/movies/similar/mvf3t1?count=10

와 같은 request를 보내게 된다.


영화 검색시에는

http://watcha.net/search.json?query=%20&page=1

와 같이 request를 보내며 javascript 로 공백을 검색하는것을 막아 뒀지만,


http://watcha.net/search.json?query=+ 와 같은 형태로 우회할 수 있다.


그래서 watcha가 가지고 있는 영화 DB의 갯수가 대략 6만개 정도라고 예상했다.


네이버의 DB가 약 9만개인 점을 생각한다면 적다고 생각했지만, 네이버와 달리

드라마 정보가 적기 때문이라고 생각했다.


대충 소스를 짜서 돌려본 결과 아래와 같은 계정을 만들 수 있었고,


무한 로딩


추천하는 영화가 없음


위와 같이 평소에 보지 못했던 새로운 메세지를 볼 수 있었다 :)

( 하지만 페이지 로딩 시간은 상당히 길어졌다 )


쿼리를 바꿔보면 새로운 쿼리를 찾을 수 도 있을것 같지만, 호기심은 해결되었으니 더 둘러보지는 않았다.


나는 이 글을 통해 왓챠가 보안에 취약하다는 것을 말하려고 하는 것은 아니다.

단지, 평소에 즐겨 쓰던 서비스였기 때문에 애정이 많이 가지만,

DB가 생각했던것보다 많이 공개되어 있어서 조금 조심할 필요가 있다고 생각된다.


사실 웹 개발에 대한 지식이 부족해서 어떻게 개선할 수 있을지는 잘 모르겠다..


마지막으로 다른분들은 이런 잉여짓을 하지 않기를 바란다...

[Python] Twitter hacking


The title is somewhat attractive but I'm not (maybe can't) going to talk about hacking the Twitter server.

As you know, Twitter is a well known social network and lots of people use Twitter openly and share his or others information through Twitter.

But some people use their account privately, which means they use Twitter to communicate with his friends.

These people tends to make mistake like twit his personal information on Twitter.




So, I want to show you how easily people can be hacked through Twitter.

I took this experiment few months ago and I could get 1560 different phone numbers in one week...


DO NOT USE THIS FOR REAL HACKING!

Just be careful when you use SNS or internet.


  1. # -*- coding:utf-8 -*-
  2. import time
  3. from twitter import *
  4. import re
  5. import MySQLdb
  6. DB_NAME = 'twitter'
  7. DB_TABLE = 'phone'
  8. # tid bigint(20), name varchar(20), text text, number bigint(20)
  9. DB_ID = 'carpedm20'
  10. DB_PASS = ' '
  11. db = MySQLdb.connect(host="", user=DB_ID, db=DB_NAME, passwd=DB_PASS, port=3306)
  12. cur = db.cursor()
  13. OAUTH_TOKEN = ''
  14. OAUTH_SECRET = ''
  15. CONSUMER_KEY = ''
  16. CONSUMER_SECRET = ''
  17. = Twitter( auth=OAuth(OAUTH_TOKEN, OAUTH_SECRETCONSUMER_KEY, CONSUMER_SECRET)
  18. findNum = re.compile(r'regular expression for phone number')
  19. while 1:
  20.         print "= start at " + time.ctime() + " ="
  21.         output = t.search.tweets(q="010",lang='ko',count='100')
  22.         print output['search_metadata']['count']
  23.         for s in output['statuses']:
  24.                 tid =  s['id']
  25.                 name = s['user']['name'].encode('utf-8')
  26.                 text = s['text'].replace("'","").encode('utf-8')
  27.                 number = findNum.findall(s['text'])
  28.                 upload_time = s['created_at'].encode('utf-8')
  29.                 if number is []:
  30.                         continue
  31.                 query = "SELECT * FROM "+DB_TABLE+" WHERE tid="+str(tid)
  32.                 cur.execute(query)
  33.                 if cur.fetchone() != None:
  34.                         continue
  35.                 for n in number:
  36.                         query = "INSERT INTO "+DB_TABLE+" (`tid`,`name`,`text`,`number`,`time`) VALUES("+str(tid)+",'"+name+"','"+text+"','"+str(n)+"','"+upload_time+"');"
  37.                         print query
  38.                         try:
  39.                                 cur.execute(query)
  40.                                 db.commit()
  41.                         except:
  42.                                 print "ERROR : " + query
  43.         time.sleep(30)

2013년 12월 2일 월요일

컴공아 일하자 (Comgong Job)

Comgong Job


What is Comgong Job

This is a python code for Comgong Job bot.
This is a program that uploads newest internship and recruit announcements to facebook automatically.

Links

Copyright

Copyright (c) 2013 Kim Tae Hoon

Screenshots


* 2015.04.17 *



* 2014.05.31 *



* 2013.12.05 *