Your SlideShare is downloading. ×
0
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Acme minechan
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Acme minechan

6,329

Published on

Perlで無理ゲーム攻略 (How to play Win32::GuiTest) …

Perlで無理ゲーム攻略 (How to play Win32::GuiTest)
http://yapcasia.org/2011/talk/32

某MMORPGでゲーム中にPerlの同時起動を遮断する機能が追加されたことがありました。
Win32::GuiTest や Win32::Screenshot などのモジュールを利用して、Windows上で
動作するゲームを自動でプレイするPerlプログラムを作成する方法について解説します。

Once upon a time, perl.exe was banned during a game by MMORPG.
I will explain how to create the Perl bot program which plays
automatically games on Windows using some modules such as
Win32::GuiTest and Win32::Screenshot.

Published in: Technology, Art & Photos
6 Comments
5 Likes
Statistics
Notes
No Downloads
Views
Total Views
6,329
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
13
Comments
6
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Perlで無理ゲーム攻略How to play Win32::GuiTest TAKESAKO <takesako@shibuya.pm.org>
  • 2. 昔むかしOnce upon a time
  • 3. あるところに MMORPG がThere was a MMORPG
  • 4. Perl.exe を遮断しましたperl.exe was banned
  • 5. http://www.ragnarokonline.jp/news/information/notice/item/7732
  • 6. Perl.exe was banned…
  • 7. Perl.exe was banned…
  • 8. Why?どうして?
  • 9. RMT (Real Money Trading) on MMORPGVirtual Money  Real Money
  • 10. Making Bot (Computer game bot) with Perl
  • 11. Hardware Bot
  • 12. Hardware Bot
  • 13. Making Software Bot1. Network emulation packet, socket, LWP (Perl)2. Web Application Selenium Core (JavaScript) Selenium IDE (Firefox extension) Selenium RC (Java/Python)3. Windows Application Win32::GuiTest (Perl) Win32::Screenshot (Perl)
  • 14. s.a. @turugina 日常業務でperlを使おう http://yapcasia.org/2011/talk/109
  • 15. Demo
  • 16. (1) Win32::GuiTestSendKeys($keys[,$delay])use Win32::GuiTest qw(SendKeys);system("start notepad.exe"); # &sleep(1);SendKeys("foo{ENTER}");SendKeys("bar{ENTER}");SendKeys("bar{BS}z{ENTER}");
  • 17. SendKeys($keys) Name Action Name Action{BACKSPACE} Backspace {PRTSCR} Print screen{BS} Backspace {RIGHT} Right arrow{BKSP} Backspace {SCROLL} Scroll lock{BREAK} Break {TAB} Tab{CAPS} Caps Lock {UP} Up arrow{DELETE} Delete {PAUSE} Pause{DOWN} Down arrow {F1} Function Key 1{END} End ... ...{ENTER} Enter {F24} Function Key 24{ESCAPE} Escape {SPC} Spacebar{HELP} Help key {SPACE} Spacebar{HOME} Home {SPACEBAR} Spacebar{INSERT} Insert {LWI} Left Windows Key{LEFT} Left arrow {RWI} Right Windows Key{NUMLOCK} Num lock {APP} Open Context Menu{PGDN} Page down Key{PGUP} Page up
  • 18. (2) FindWindowLike, GetWindowRectGetWindowText, GetClassNameuse Win32::GuiTest qw(:ALL);system("start calc.exe");sleep(1);my @id = FindWindowLike(undef,"^電卓","",undef,1);my $id = $id[0];print GetWindowText($id), "¥n";print GetClassName ($id), "¥n";my ($x1, $y1, $x2, $y2) = GetWindowRect($id);print "($x1, $y1)->($x2, $y2)", "¥n";
  • 19. (3) Win32::ScreenshotCaputureRect #=> Image::Magick object use Win32::Screenshot qw(CaptureRect); my $img = CaptureRect(20, 10, 800, 500);print $img; # Image::Magick=ARRAY(0xbeef) $img->Write("x.png"); # save system("start x.png"); # view
  • 20. (4) Win32::GuiTest & Win32::ScreenshotCapture only “calc.exe” windowuse Win32::GuiTest qw(:ALL);use Win32::Screenshot qw(CaptureRect);system("start calc.exe");sleep(1);my @id = FindWindowLike(undef,"^電卓","",undef,1);my ($x1, $y1, $x2, $y2) = GetWindowRect($id[0]);my $img = CaptureRect($x1,$y1, $x2-$x1,$y2-$y1); $img->Write("x.png"); # save system("start x.png"); # view
  • 21. (5) {Image::Magick}->Get("signature")Image binary  SHA-256 digest string use Win32::Screenshot qw(CaptureRect); my $img = CaptureRect(20, 10, 800, 500); $img; # Image::Magick=ARRAY(0xbeef)print $img->Get("signature"),"¥n"; # SHA-256 $img = new Image::Magick; $img->Read("x.png");print $img->Get("signature"),"¥n"; # SHA-256
  • 22. (6) Win32::GuiTest でマウスを操作するMouseMoveAbsPix($x, $y)use Win32::GuiTest qw(:ALL);for ($x = 0; $x < 900; $x += 2) { $y = sin($x / 60) * 300 + 400; MouseMoveAbsPix($x, $y);}
  • 23. (7) Win32::GuiTest でマウスをクリックするSendMouse($command)use Win32::GuiTest qw(:ALL);for (1..5) { SendMouse("{LEFTCLICK}"); sleep(1); SendMouse("{RIGHTCLICK}"); sleep(1);}
  • 24. Win32::GuiTest::SendMouse($command){LEFTDOWN} left button down{LEFTUP} left button up{MIDDLEDOWN} middle button down{MIDDLEUP} middle button up{RIGHTDOWN} right button down{RIGHTUP} right button up{LEFTCLICK} left button single click{MIDDLECLICK} middle button single click{RIGHTCLICK} right button single click{ABSx,y} move to absolute coordinate{RELx,y} move to relative coordinate
  • 25. 応用問題practical lesson
  • 26. 無理ゲー攻略mission impossible
  • 27. Acme::MineChan マイン ちゃん Minesweeper を ちゃんと解く。
  • 28. Demo
  • 29. 画像ファイルだけ、座標データは不要
  • 30. FAQ. 役に立つの?新しいスクリーンセーバーとして鑑賞する Fun of the New Screen Saverタイピングソフトでハイスコアを出す Scoring champion for Key-Typing softwareWindowsアプリの自動テスト化 Automation Testing for Win32 Applicationsセキュリティ脆弱性検査 Fuzzingその他 etc.
  • 31. How toDebug
  • 32. 40
  • 33. 暴走runaway
  • 34. I Cannot control keyboard and mouse!
  • 35. Oh…
  • 36. Press Ctrl+C
  • 37. infinite loooooooooooooop!!!(無限ループ)
  • 38. I cannot use keyboard and mouse!!!
  • 39. I want to kill
  • 40. How to Kill the process on Win32XP, 2003 Server … New command line toolstasklist プロセスを一覧表示するtaskkill /F /IM notepad.exe プロセスを kill する 成功: プロセス "notepad.exe" (PID 777) は強制終 了されました。
  • 41. How to kick?I cannot use keyboard and mouse…
  • 42. USB! USB!
  • 43. Perl Killer USB Memory!autorun.inf[Autorun]open=taskkill /F /IM perl.exe
  • 44. Insert USB Memory…
  • 45. Successful!
  • 46. Assign Desktop Shortcut Key (Ctrl+Alt+?)KILLPERL.BAT  Shortcut  Desktop@echo offtaskkill /F /IM perl.exe
  • 47. Ctrl + Alt + K
  • 48. Perl is dead!
  • 49. 以上
  • 50. all your minesweeper are belong to us!
  • 51. 61
  • 52. 参考文献 Win32::GuiTest で Windows の GUI アプリをハックしよう(あまちゃん)  http://perl-users.jp/articles/advent-calendar/2008/13.html Win32::GUITest と Win32::Clipboard で GUI 操作を自動化する(xaicron)  http://perl-users.jp/articles/advent-calendar/2010/win32/8 How To Get a Window Handle Without Specifying an Exact Title  http://support.microsoft.com/kb/147659/en Minesweeper Clone  http://www.minesweeper.info/wiki/Minesweeper_Clone アプリケーションをショートカット キーで起動する  http://www.microsoft.com/japan/athome/magazine/ucontents/users/tips/ windows/041.aspx @turugina 日常業務でperlを使おう  http://yapcasia.org/2011/talk/109 @keroyonn_ Perlで次世代ゲーム開発 あらため Perl で次世代CUIゲーム開発  http://yapcasia.org/2011/talk/121
  • 53. 謝辞acknowledgement
  • 54. CPAN++

×