Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20140904_(cyber_security)_How_to_automate_webhacking.kr_with_Python_presentation

re4lfl0w
September 22, 2015

 20140904_(cyber_security)_How_to_automate_webhacking.kr_with_Python_presentation

20140904_(cyber_security)_How_to_automate_webhacking.kr_with_Python_presentation

re4lfl0w

September 22, 2015
Tweet

Other Decks in Programming

Transcript

  1. Who are you? • ઑӔ৔, թ੗ࢎۈ • Python જইೣ •

    Data Analysis, TDD, Penetration Testing, DevOps, Machine Learning, NLP ҙब • githubgithub • ౵ਵܻॆ ਍৔੗euripy euripy http://euripy.github.io github https://github.com/re4lfl0w/ How to automate webhacking.kr with Python © ઑӔ৔ 2015 2
  2. Casting • ܻ࠭1 1 Hardware Hacking Training Epilogue How to

    automate webhacking.kr with Python © ઑӔ৔ 2015 3
  3. ੌ߈੸ੋ ಽ੉ח ցޖ ݆׮!! જই? Ӓۧ׮ݶ ର߹ചܳ ೞӝ ਤ೧ࢲח?? How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 7
  4. જই... Webhacking.kr ࢎր ೞ۞ оࠁ੗ ੌױ ݾରܳ ೠ ߣ ࠊࠅө

    How to automate webhacking.kr with Python © ઑӔ৔ 2015 12
  5. 1ੌର • ੉ۿ ߂ पण ળ࠺ • դ੉ب ೞ ޙઁ

    ಽ੉(੗߄झ௼݀౟, ౵ۄ޷ఠ ߸ઑ) How to automate webhacking.kr with Python © ઑӔ৔ 2015 13
  6. 2ੌର • դ੉ب ઺ ޙઁ ಽ੉(౵ۄ޷ఠ ߸ઑ, XSS ١) How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 14
  7. 3ੌର • դ੉ب ઺ ~ ࢚ ޙઁ ಽ੉(SQL Injection) How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 15
  8. ଼ਵ۽ח ݆੉ ࠌחؘ ޙઁ ಽ੉ח ݆੉ ೧ࠁ૑ ঋ਺ જই! ب੹੉׮

    How to automate webhacking.kr with Python © ઑӔ৔ 2015 17
  9. Key Point • ղо ݈ೞҊ੗ ೞחѪ਷ ޙઁܳ ݃઱ଢ଼ਸ ٸ যڌѱ

    ೧ Ѿೞח૑? How to automate webhacking.kr with Python © ઑӔ৔ 2015 19
  10. Key Point • ղо ݈ೞҊ੗ ೞחѪ਷ ޙઁܳ ݃઱ଢ଼ਸ ٸ যڌѱ

    ೧ Ѿೞח૑? • ঐޗ૑ী ੓ח ࢎҊ੄ җ੿ਸ ࠁৈ઱חؘ ୡ੼ How to automate webhacking.kr with Python © ઑӔ৔ 2015 20
  11. Key Point • ղо ݈ೞҊ੗ ೞחѪ਷ ޙઁܳ ݃઱ଢ଼ਸ ٸ যڌѱ

    ೧ Ѿೞח૑? • ঐޗ૑ী ੓ח ࢎҊ੄ җ੿ਸ ࠁৈ઱חؘ ୡ੼ • Ѿҗܳ ٜ݅যࢲ ؀ױೞ૑? ۄחѱ ੉ ठۄ੉٘ীࢲ ਗ ೞחѱ ইש How to automate webhacking.kr with Python © ઑӔ৔ 2015 21
  12. Key Point • ղо ݈ೞҊ੗ ೞחѪ਷ ޙઁܳ ݃઱ଢ଼ਸ ٸ যڌѱ

    ೧ Ѿೞח૑? • ঐޗ૑ী ੓ח ࢎҊ੄ җ੿ਸ ࠁৈ઱חؘ ୡ੼ • Ѿҗܳ ٜ݅যࢲ ؀ױೞ૑? ۄחѱ ੉ ठۄ੉٘ীࢲ ਗ ೞחѱ ইש • ૒ҙ, ੄ࢎѾ੿, ࢚ട౵ঈ ١ਸ যڌѱ ೮ח૑ ࠁৈ઱ח ѱ Point How to automate webhacking.kr with Python © ઑӔ৔ 2015 22
  13. ੗زചী ೙ਃೠ ࣽࢲ 1. ۽Ӓੋ 2. ޙઁ ࠁӝ • Highlight

    ޙઁ • ੿۳ ޙઁ 3. ޙઁ ࣗझ ࠁӝ 4. ੋૐೞӝ How to automate webhacking.kr with Python © ઑӔ৔ 2015 23
  14. ۽Ӓੋ ੿ࠁܳ ਬ૑ೞӝ ਤೠ ౵੉ ॆ ۄ੉࠳۞ܻо ޤо ੓૑? How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 27
  15. ইೞ! POST method۽ id, pwܳ ੋ੗۽ ֈӝחҳա. How to automate

    webhacking.kr with Python © ઑӔ৔ 2015 33
  16. Login Mechanize Source import mechanize import urllib import urlparse from

    custom_source.login import id_, pw login_url = 'http://webhacking.kr/index.html?enter=1' data = urllib.urlencode({'id':id_, 'pw':pw}) browser = mechanize.Browser() resp = browser.open(login_url, data).read() How to automate webhacking.kr with Python © ઑӔ৔ 2015 34
  17. No. 15 • ݾ੸: ੗߄झ௼݀౟ ࣗझ ഛੋ How to automate

    webhacking.kr with Python © ઑӔ৔ 2015 36
  18. Print source resp = browser.open(index_url).read() resp = browser.open(challenge_url).read() def join_url(url,

    base_url='http://webhacking.kr'): if 'view-source:' in url: url = url.replace('view-source:', '') if 'webhacking' in url and 'http' not in url: return '{0}{1}'.format('http://', url) return urlparse.urljoin(base_url, url) def print_source(url): resp = browser.open(join_url(url)).read() print(resp) return resp print_source('challenge/javascript/js2.html') How to automate webhacking.kr with Python © ઑӔ৔ 2015 37
  19. Colorful ೞ૑ب ঋҊ, Syntax Highlightب উغয ੓Ҋ, Python ਬ੷ীѱח Ӓ੷

    Ҋդҗ ৉҃ How to automate webhacking.kr with Python © ઑӔ৔ 2015 39
  20. જই, Syntax Highlightо غח Ѫ ਸ ଺ইࠁ੗! How to automate

    webhacking.kr with Python © ઑӔ৔ 2015 40
  21. Pygments? ޤ૑?1 This is the home of Pygments. It is

    a generic syntax highlighter suitable for use in code hosting, forums, wikis or other applications that need to prettify source code. Highlights are: • a wide range of over 300 languages and other text formats is supported • special attention is paid to details that increase highlighting quality How to automate webhacking.kr with Python © ઑӔ৔ 2015 42
  22. Pygments? ޤ૑?2 • support for new languages and formats are

    added easily; most languages use a simple regex-based lexing mechanism • a number of output formats is available, among them HTML, RTF, LaTeX and ANSI sequences • it is usable as a command-line tool and as a library ... and it highlights even Perl 6! How to automate webhacking.kr with Python © ઑӔ৔ 2015 43
  23. ৈӝ੷ӝ ҳӖ݂ ೞݶࢲ ଺ই׮פ׮ য٣ࢲ ࠌח૑ח ӝর੉ ա૑ ঋ૑݅ ৘ઁܳ

    ଺ও׮. ब ࠌ׮! How to automate webhacking.kr with Python © ઑӔ৔ 2015 47
  24. ੸ਊೞӝ ਤೠ ࢎ੹ ѐ֛ ೙ਃ pygments.highlight(code, lexer, formatter, outfile=None) •

    code: ੸ਊೞҊ੗ ೞח code • lexer: যڃ languageܳ highlight ೡ Ѫੋ૑?(ex: Python, C) • formatter: যڃ झఋੌਸ ࢎਊ ೡ Ѫੋ૑?(ex: default, friendly) • highlight: ୭ઙ ੸ਊೡ code, lexer, formatter ҳ೧ࢲ ֍য ઱੗! How to automate webhacking.kr with Python © ઑӔ৔ 2015 48
  25. Pygments original source lexer = get_lexer_by_name('html') formatter = HtmlFormatter(style='default', linenos=False,

    full=True) data = highlight(response, lexer, formatter) HTML(data=data) • HTML: IPython Notebookীࢲ HTMLਸ ࡸ۰઱ח ৉ೡ How to automate webhacking.kr with Python © ઑӔ৔ 2015 49
  26. Ӕؘ ই૒ ੿۳੉ উع׮. ੉ઁ ࣗझী ੿۳೧઱ח beautifierܳ ࠢৈࠁ੗ How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 53
  27. beautifier റࠁҵ 1. original 2. jsbeautifier 3. beautifulsoup How to

    automate webhacking.kr with Python © ઑӔ৔ 2015 54
  28. beautifier റࠁҵ ޙઁ੼ 1. original: ࣗझ ੿۳ উؽ 2. jsbeautifier:

    indent ؽ, tag ࢎ੉ী space ٜযо ח ޙઁ੼. • ৡۄੋ Online JavaScript beautifierח ੉۠ ޙ ઁ੼੉ হחؘ ޤо ޙઁੌө? issue ৢܿ 3. beautifulsoup: script উ੄ ࣗझо indentо উؽ How to automate webhacking.kr with Python © ઑӔ৔ 2015 56
  29. Ӓ݅ ఋഈೞ੗... Ӓա݃ html਷ ઁ؀۽ ੿۳੉ غחѦ ఖೞ੗ 3ߣ beautifulsoup

    ਸ ࢶఖೞҊ ޙઁ ಽ੗!! How to automate webhacking.kr with Python © ઑӔ৔ 2015 58
  30. No.15 Auth • ޙઁ੼੉: ੋૐ߉ӝ ਤ೧ ੌੌ੉ ੑ۱೧ঠ ؽ..୓௼ ನ

    ੋ౟ How to automate webhacking.kr with Python © ઑӔ৔ 2015 60
  31. No. 17 • ݾ੸: ੗߄झ௼݀౟ ߸ࣻ ч ഛੋ How to

    automate webhacking.kr with Python © ઑӔ৔ 2015 61
  32. ੌױ Python ਵ۽ ೧Ѿ೧ ࠁ੗! unlock = 100*10*10+100/10-10+10+50-9*8+7-6+5-4*3-2*1*10*100*10*10+100/10-10+10+... print(unlock/10) #

    python2 # 999780950 # python3 # 999780930.7 python2৬ python3ח division Ѿҗо ׮ܰ׮. python2ীࢲ python3৬ زੌೠ Ѿҗܳ ঳ӝ ਤ೧ ࢲ ୶оೞ੗ from __future__ import division How to automate webhacking.kr with Python © ઑӔ৔ 2015 64
  33. ೼೼... য૰ٚ Python ਵ۽ ೧Ѿೞӟ ೮૑݅ ׮਺ীח যڌѱ ೧Ѿ೧ঠ ೡ૑...

    How to automate webhacking.kr with Python © ઑӔ৔ 2015 66
  34. No. 14 • ݾ੸: ߸ࣻ৬ ೣࣻ, onclick() ࢎਊߨ How to

    automate webhacking.kr with Python © ઑӔ৔ 2015 67
  35. Print Source No.14 resp = print_source('webhacking.kr/challenge/javascript/js1.html') <html> ... <form name="pw">

    <input type="text" name="input_pwd" /> <input type="button" value="check" onclick="ck()" /> </form> <script> function ck() { var ul=document.URL; ul=ul.indexOf(".kr"); ul=ul*30; if(ul==pw.input_pwd.value) { alert("Password is "+ul*pw.input_pwd.value); } else { alert("Wrong"); } } </script> </body> </html> How to automate webhacking.kr with Python © ઑӔ৔ 2015 68
  36. Chrome Development Tool & IPython ޙઁ੼: DOMী ੄೧ ࢤࢿغח document.URLਸ

    ੌੌ੉ ࠂࠢ೧ঠ ೠ׮. ૊, DOMਸ ઁয೧ঠ ೠ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 69
  37. ణॅ... ٘٣য DOM੉ ա৳ҳա4 যڌѱ ೧Ѿ೧ঠ ೞ૑? 4 DOM(Document Object

    Model) How to automate webhacking.kr with Python © ઑӔ৔ 2015 70
  38. അ੤ө૑ աఋդ ޙઁ੼ 1. ࣗझ ઱ࣗܳ ೠٲೠٲ ࠳ۄ਋੷ীࢲ ࠂࠢਸ ೧ঠೠ׮.

    2. javascriptܳ प೯ೡ ࣻ ੓חо? • प೯ೡ ࣻ ੓׮Ҋ ೧ب ࠳ۄ਋੷ী ઙࣘ੸ੋ ࢚ടী ࢲח যڌѱ ೡ Ѫੋо?(ex: DOM) 3. ࠳ۄ਋੷ী ೠٲೠٲ ࠂࠢਸ ೧ࢲ ੋૐਸ ೠ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 73
  39. ڂߏ ైୋ • दр: 9ਘ 4ੌ Әਃੌ ੷֘7द~9द • ੢ࣗ:

    ъթషૉఋਕ 2க How to automate webhacking.kr with Python © ઑӔ৔ 2015 74
  40. ୌ݃٣੄ ݈ࠁ׮ ೠ ߣ ࠁח ѱ ؊ ի׮ ޤೞח ֧ੋ૑ח

    ݢ੷ ࠁҊաࢲ Ҋ޹ How to automate webhacking.kr with Python © ઑӔ৔ 2015 79
  41. Selenium Simple Source from urllib import quote from urlparse import

    urljoin from time import sleep from selenium import webdriver driver = webdriver.Firefox() google_url = 'https://google.com/' sleep(5) driver.get(google_url) sleep(5) query = 'python' search_url = urljoin(google_url, 'search?q={}'.format(quote(query))) driver.get(search_url) sleep(10) driver.quit() How to automate webhacking.kr with Python © ઑӔ৔ 2015 81
  42. Why Selenium?1 • Frequent regression testing(੗઱ೞח ഥӈ పझ ౴) •

    Rapid feedback to developers(ѐߊ੗ীѱ ࡅܲ ೖ٘ߔ) • Virtually unlimited iterations of test case execution(о࢚ਵ۽ ઁೠহ੉ పझ౟ ா੉झ प೯) • Support for Agile and extreme development methodologies(ࡅܲ ѐߊ ߑߨۿਸ ૑ਗ) How to automate webhacking.kr with Python © ઑӔ৔ 2015 82
  43. Why Selenium?2 • Disciplined documentation of test cases(ӏѺ ച ػ

    పझ౟ ா੉झ੄ ޙࢲച) • Customized defect reporting(ѐѐੋ੄ ਃҳী ݏ ୸ ܻನ౴) • Finding defects missed by manual testing(ࣻز పझ౟۽ ࢤӝח Ѿೣਸ ଺ӝ) How to automate webhacking.kr with Python © ઑӔ৔ 2015 83
  44. ݈੉ ҭ੢൤ য۵׮... UI ߡӒܳ ࡅܲ दрղী ੟ӝ ਤ೧ࢲ పझ౟

    ೠ׮ח ѐ֛ਵ۽ ࠁݶ ؽ ࢎਊ੗ झషܻী ٮۄࢲ పझ౟ೞח Function Testingীب ࢎਊ ؽ դ 'Ӓ੷ ੗زച بҳ'۽ࢲ੄ दпਵ۽ ߄ۄࠆ How to automate webhacking.kr with Python © ઑӔ৔ 2015 84
  45. അ੤ө૑ աఋդ ޙઁ੼ 1. ࣗझ ઱ࣗܳ ೠٲೠٲ ࠳ۄ਋੷ীࢲ ࠂࠢਸ ೧ঠೠ׮.

    2. javascriptܳ प೯ೡ ࣻ ੓חо? • प೯ೡ ࣻ ੓׮Ҋ ೧ب ࠳ۄ਋੷ী ઙࣘ੸ੋ ࢚ടী ࢲח যڌѱ ೡ Ѫੋо?(ex: DOM) 3. ࠳ۄ਋੷ী ೠٲೠٲ ࠂࠢਸ ೧ࢲ ੋૐਸ ೠ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 86
  46. ࠳ۄ਋੷ח যରೖ sourceܳ ߉ই৬ࢲ rendering ೧઱ח Ѫ߆ী হਗ਼ই? Ӓۧ׮ݶ ղо

    sourceীࢲ ઱ࣗܳ ঳যয়ݶ غ૑ঋա?! How to automate webhacking.kr with Python © ઑӔ৔ 2015 90
  47. onclick event Excute a JavaScript when a button is clicked

    <script> function myFunction() { document.getElementById("demo").innerHTML = "Hello World"; } </script> <button onclick="myFunction()">Click me</button> Hello Worldо ୹۱ػ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 95
  48. location.href Return the entire URL(of the current page) location.href='http://google.com' ੉۞ݶ

    ಕ੉૑о ҳӖ۽ ੉زೠ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 96
  49. Ӓۧ׮ݶ... ੷ onclick੄ ࣘࢿਸ ୶୹ೠ റী location.href੄ ࣘࢿਸ ୶୹ೞݶ challenge/web/web-01/

    ݅ ঳য૓׮ח ݈ॹ? How to automate webhacking.kr with Python © ઑӔ৔ 2015 98
  50. XPath XPath(XML Path Language)ח W3C੄ ಴ળਵ۽ ഛ੢ ࢤࢿ ঱য ޙࢲ੄

    ҳઑܳ ా೧ ҃۽ ਤী ૑੿ೠ ҳޙਸ ࢎ ਊೞৈ ೦ݾਸ ߓ஖ೞҊ ୊ܻೞח ߑߨਸ ӝࣿೞח ঱য੉ ׮. XML ಴അࠁ׮ ؊ औҊ ডয۽ غয ੓ਵݴ, XSL ߸ജ (XSLT)җ XML ૑द੗ ঱য(XPointer)ী ॳ੉ח ঱য੉ ׮. XPathח XML ޙࢲ੄ ֢٘ܳ ੿੄ೞӝ ਤೞৈ ҃۽ध ਸ ࢎਊೞݴ, ࣻ೟ ೣࣻ৬ ӝఋ ഛ੢ оמೠ ಴അٜ੉ ੓ ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 100
  51. ৉द ঱ઁա ٯٯೠ ੿੄ח য۰ਕ.. ੉೧ೞӝ औѱ exampleਸ ࠁ੗ How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 101
  52. title਷ ੜ ୶୹੉ ع׮. //title਷ title tagܳ //title/text()ח title੄ text݅(਋ܻо

    ਗೞ؍ Ѫ!) How to automate webhacking.kr with Python © ઑӔ৔ 2015 103
  53. ݃਋झ۽ ନ਷ XPathܳ ࠁפ ҭ੢൤ য۵ѱ աఋա ੓׮. html/body/table/tbody/tr[2]/td/center/center/form/table/tbody/tr[1]/td[1]/input ੉Ѣ

    о૑Ҋ ޥо ୶୹ೞӝۆ ҭ੢൤ য۰਎ Ѫ э׮. ցޖ specific ೧. ௾ ౣ݅ ౵ঈೞҊ ߸ഋ೧ࠁ੗! How to automate webhacking.kr with Python © ઑӔ৔ 2015 106
  54. XPath ഝਊ೧ࢲ onclick ࣘࢿ ୶୹ ੄ب஖ঋѱ IDо ࢶఖ੉ ػ׮. ੉۠Ѫਸ

    ੜ ୊ܻ೧ ઱੗ How to automate webhacking.kr with Python © ઑӔ৔ 2015 109
  55. ޙઁٜ੄ input tag݅ ࢶఖؽ webhacking.kr੄ ୨ ޙઁࣻח 66ޙઁ׮. ೞ૑݅ IDч੉

    ઁੌ ୊਺ী ನೣغ ӝ ٸޙী 67ѐ੄ ֢٘о ୶୹ػ Ѫਸ ഛੋ оמ How to automate webhacking.kr with Python © ઑӔ৔ 2015 110
  56. Tag & Attribute ର੉੼ Tag: form, table, tbody, tr, td

    Attribute: type, onclick, style, background, color, onmouseout, onmouseover How to automate webhacking.kr with Python © ઑӔ৔ 2015 113
  57. @ܳ ࠢৈ઱ݶ Attribute ੽Ӕ о מ //form/table/tbody/tr/td/input/@onclick प਷ աب Attribute

    ୶ ୹ೞח Ѫਸ ߊ಴ ળ࠺ೞݶ ࢲ ӵ׳ও׮. ৉द ߊ಴ೞחѤ ߊ಴੗ী ѱ ؊ ب਑੉ غח ੌ How to automate webhacking.kr with Python © ઑӔ৔ 2015 114
  58. Ӓۢ ੉ઁ sourceױীࢲ Parsing੉ оמೞ޲۽ ࠂࠢਸ ೞ૑ ঋইب ػ׮. How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 115
  59. അ੤ө૑ աఋդ ޙઁ੼ 1. ࣗझ ઱ࣗܳ ೠٲೠٲ ࠳ۄ਋੷ীࢲ ࠂࠢਸ ೧ঠೠ׮.

    2. javascriptܳ प೯ೡ ࣻ ੓חо? • प೯ೡ ࣻ ੓׮Ҋ ೧ب ࠳ۄ਋੷ী ઙࣘ੸ੋ ࢚ടী ࢲח যڌѱ ೡ Ѫੋо?(ex: DOM) 3. ࠳ۄ਋੷ী ೠٲೠٲ ࠂࠢਸ ೧ࢲ ੋૐਸ ೠ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 116
  60. Ӓۢ ੉ઁ যו ੿ب ળ࠺о ՘դѪ э׮. Selenium ਵ۽ ۽Ӓੋࠗఠ

    ׮द! How to automate webhacking.kr with Python © ઑӔ৔ 2015 117
  61. Login Logic 1. Connect Login Webpage 2. Input ID How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 121
  62. Login Logic 1. Connect Login Webpage 2. Input ID 3.

    Input PW How to automate webhacking.kr with Python © ઑӔ৔ 2015 122
  63. Login Logic 1. Connect Login Webpage 2. Input ID 3.

    Input PW 4. Click Login button How to automate webhacking.kr with Python © ઑӔ৔ 2015 123
  64. webhacking.kr Login Analysis <form method="post" action="index.html?enter=1" name="lf" onkeypress="if(event.keyCode==13)go();"> </form> function

    go() { if(lf.id.value=="") { lf.id.focus(); return; } if(lf.pw.value=="") { lf.pw.focus(); return; } lf.submit(); } How to automate webhacking.kr with Python © ઑӔ৔ 2015 124
  65. webhacking.kr Login Analysis <form method="post" action="index.html?enter=1" name="lf" onkeypress="if(event.keyCode==13)go();"> </form> function

    go() { if(lf.id.value=="") { lf.id.focus(); return; } if(lf.pw.value=="") { lf.pw.focus(); return; } lf.submit(); } ۽Ӓੋ ೞ۰ݶ javascriptܳ ॄঠغ֎?! How to automate webhacking.kr with Python © ઑӔ৔ 2015 125
  66. ೙ਃೠ ೣٜࣻ ݢ੷ Import # built-in import urllib import urlparse

    import re import time # third-party import jsbeautifier import mechanize from selenium import webdriver from BeautifulSoup import BeautifulSoup as bs from pygments import highlight from pygments.lexers import get_lexer_by_name from pygments.formatters.html import HtmlFormatter from IPython.display import HTML # custom from custom_source.login import id_, pw login_url = 'http://webhacking.kr/index.html?enter=1' index_url = 'http://webhacking.kr/index.php' challenge_url = 'http://webhacking.kr/index.php?mode=challenge' auth_url = 'http://webhacking.kr/index.php?mode=auth' How to automate webhacking.kr with Python © ઑӔ৔ 2015 126
  67. Login ҳഅ Source from urllib import quote from urlparse import

    urljoin from time import sleep from selenium import webdriver WAIT = 1 driver = webdriver.Firefox() sleep(WAIT) driver.get(login_url) sleep(WAIT) sleep(WAIT) driver.find_element_by_name('id').send_keys(id_) driver.find_element_by_name('pw').send_keys(pw) driver.execute_script('go();') # javascript प೯೧ࢲ ۽Ӓੋ! sleep(10) driver.quit() How to automate webhacking.kr with Python © ઑӔ৔ 2015 127
  68. അ੤ө૑ աఋդ ޙઁ੼ 1. ࣗझ ઱ࣗܳ ೠٲೠٲ ࠳ۄ਋੷ীࢲ ࠂࠢਸ ೧ঠೠ׮.

    2. javascriptܳ प೯ೡ ࣻ ੓חо? • प೯ೡ ࣻ ੓׮Ҋ ೧ب ࠳ۄ਋੷ী ઙࣘ੸ੋ ࢚ടী ࢲח যڌѱ ೡ Ѫੋо?(ex: DOM) 3. ࠳ۄ਋੷ী ೠٲೠٲ ࠂࠢਸ ೧ࢲ ੋૐਸ ೠ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 130
  69. Auth Analysis <form method="post" action="?mode=auth_go"> <table> <tbody> <tr> <td>Flag</td> <td>

    <input type="text" name="answer" size="100"> </td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Submit"> <br><br> Do not brute-force </td> </tr> </tbody> </table> </form> How to automate webhacking.kr with Python © ઑӔ৔ 2015 132
  70. Auth ҳഅ Source sleep(WAIT) driver.get(auth_url) sleep(WAIT) sleep(WAIT) answer = 'off_script'

    driver.find_element_by_name('answer').send_keys(answer) # nameਵ۽ب ࢶఖ оמ # css selector۽ب ࢶఖ оמ driver.find_elements_by_css_selector('form table tbody tr td input')[-1].click() sleep(WAIT) sleep(10) driver.switch_to.alert.accept() # ઺ਃ! alertହ হগ઻ঠ ೠ׮! sleep(10) How to automate webhacking.kr with Python © ઑӔ৔ 2015 133
  71. അ੤ө૑ աఋդ ޙઁ੼ 1. ࣗझ ઱ࣗܳ ೠٲೠٲ ࠳ۄ਋੷ীࢲ ࠂࠢਸ ೧ঠೠ׮.

    2. javascriptܳ प೯ೡ ࣻ ੓חо? • प೯ೡ ࣻ ੓׮Ҋ ೧ب ࠳ۄ਋੷ী ઙࣘ੸ੋ ࢚ടী ࢲח যڌѱ ೡ Ѫੋо?(ex: DOM) 3. ࠳ۄ਋੷ী ೠٲೠٲ ࠂࠢਸ ೧ࢲ ੋૐਸ ೠ׮. How to automate webhacking.kr with Python © ઑӔ৔ 2015 135
  72. Refactoring 1. login: login ҳഅ. ࢎਊ੗ id, pw ੑ۱ How

    to automate webhacking.kr with Python © ઑӔ৔ 2015 140
  73. Refactoring 1. login: login ҳഅ. ࢎਊ੗ id, pw ੑ۱ 2.

    view_challenge: challenge.html ਸ ౵य೧ࢲ ޙ ઁٜ ઱ࣗ ୶୹ How to automate webhacking.kr with Python © ઑӔ৔ 2015 141
  74. Refactoring 1. login: login ҳഅ. ࢎਊ੗ id, pw ੑ۱ 2.

    view_challenge: challenge.html ਸ ౵य೧ࢲ ޙ ઁٜ ઱ࣗ ୶୹ 3. print_problem_source: ࣗझ ୹۱ How to automate webhacking.kr with Python © ઑӔ৔ 2015 142
  75. Refactoring 1. login: login ҳഅ. ࢎਊ੗ id, pw ੑ۱ 2.

    view_challenge: challenge.html ਸ ౵य೧ࢲ ޙ ઁٜ ઱ࣗ ୶୹ 3. print_problem_source: ࣗझ ୹۱ 4. print_index_phps: ޙઁ ಕ੉૑ উ੄ ࣗझ ୹۱ How to automate webhacking.kr with Python © ઑӔ৔ 2015 143
  76. Refactoring 1. login: login ҳഅ. ࢎਊ੗ id, pw ੑ۱ 2.

    view_challenge: challenge.html ਸ ౵य೧ࢲ ޙ ઁٜ ઱ࣗ ୶୹ 3. print_problem_source: ࣗझ ୹۱ 4. print_index_phps: ޙઁ ಕ੉૑ উ੄ ࣗझ ୹۱ 5. auth: ੋૐ ಕ੉૑ How to automate webhacking.kr with Python © ઑӔ৔ 2015 144
  77. Refactoring 1. login: login ҳഅ. ࢎਊ੗ id, pw ੑ۱ 2.

    view_challenge: challenge.html ਸ ౵य೧ࢲ ޙ ઁٜ ઱ࣗ ୶୹ 3. print_problem_source: ࣗझ ୹۱ 4. print_index_phps: ޙઁ ಕ੉૑ উ੄ ࣗझ ୹۱ 5. auth: ੋૐ ಕ੉૑ 6. accept_alert: ੋૐ ಕ੉૑ীࢲ ഛੋ ߡౡ ௿ܼೞӝ How to automate webhacking.kr with Python © ઑӔ৔ 2015 145
  78. Class & Methods class webHacking(object): def __init__(self): def __del__(self): def

    login(self): def view_challenge(self): def print_problem_source(self, num): def print_index_phps(self, src='index.phps'): def auth(self, answer): def accept_alert(): How to automate webhacking.kr with Python © ઑӔ৔ 2015 146
  79. ୊਺ࠗఠ ੷ۧѱ ૞੐࢜੓ח ҳઑо աৡѤ ইפঠ. ࢗ૕ ೞ׮ࠁפө ੷ۧѱ ೞݶ

    ಞೡѪ эইࢲ աৡ ҳઑ.. ૊, ࢤп੄ ࢑ޛ How to automate webhacking.kr with Python © ઑӔ৔ 2015 149
  80. ղо ҕࠗೠ Resources 1. Selenium with Python 2. Selenium Testing

    Tools Cookbook How to automate webhacking.kr with Python © ઑӔ৔ 2015 151
  81. ನ௄ހ ࢎ૓ ୹୊ ನ௄ހझఠ ߬झ౟ਤद दો2 23ച ࢎషद ؀ ௏పஎ!

    ࠺ ޻߽ӝ ࢎਖ਼٘ۄ!! ܻ࠭ ನ௄ހझఠ ߬झ౟ਤद दો2 24ച Ѿ଱ ੒गܻӒ! How to automate webhacking.kr with Python © ઑӔ৔ 2015 152
  82. ࢎ੹ ૑ध • ੉ ૑ध੉ হਵݶ ষ୒դ ࢗ૕ ز߈ೣ! •

    virtualenv • pip How to automate webhacking.kr with Python © ઑӔ৔ 2015 153
  83. ա઺ী ୶оೡ ղਊٜ • print_problem_source, print_index_phps ࢸݺ (ppt ݅٘ח दр੉

    Ԩ ݆੉ ٚ׮. 40दр ੿ب ॵ٠.) • Proxy ੸ਊ೧ࢲ ౵ۄ޷ఠ ߸ઑ(੉ѱ ઁੌ х੉ উ ੟ ൩) • য૸ ࣻ হ੉ Fiddlerա Burp Suiteܳ ॄঠೡ٠ • XSS • SQL Injection • sqlmap How to automate webhacking.kr with Python © ઑӔ৔ 2015 154