SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
はせがわようすけ
Yosuke HASEGAWA
第1部
WindowsでもPerlを使いたい
How can I use Perl on Windows?
WindowsでもPerlを使いたい!
   How can I use Perl on Windows?



それ、ActivePerlでできるよ!
You can do that with ActivePerl!
第1部 完
第2部
PerlからDLLを呼びたい!
Calling DLL from Perl!
PerlからDLLを呼びたい!
   Calling DLL from Perl!
❤それ、Win32::APIでできるよ!
use Win32::API;

my $MessageBox = Win32::API->new(     DLL名
   quot;user32quot;,
                                      関数名
   quot;MessageBoxAquot;,
   quot;NPPNquot;,                引数:整数、ポインタ、ポインタ、整数
   quot;Nquot;
                                    戻り値:整数
);

$MessageBox->Call( 0,
  quot;Happy Weddingquot;, quot;Perlquot;, 0 );
第2部 完
第3部
    Perlからx86コードを
         呼びたい!
Calling x86 code from Perl
Perlからx86コードを呼びたい!
   Calling x86 code from Perl
❤シグナルハンドラを利用
 Using signal handlers
 ❤実行コードのバイト列を用意
   Preparing binary array for executable code
 ❤シグナルハンドラとしてバイト列を指定
   Assign the array as a signal handler
 ❤シグナルの生成
   Raise signal to call binary code
❤ActivePerlはヒープごとDEP解除?
 Disabled DEP for all of heap area?
Perlからx86コードを呼びたい!
      Calling x86 code from Perl
❤シグナルハンドラでやってみた
                                                      シグナルハンドラ
my   $x86 = quot;quot;
                                                      実効するコード
.    quot;¥x83¥x7d¥x08¥x00quot;   #   cmp [dwCtrlEvent], 0
.    quot;¥x74¥x05quot;           #   je if( not Ctrl+C ) return
.    quot;¥x33¥xc0quot;           #   xor eax, eax
.    quot;¥xc2¥x04¥x00quot;       #   ret 4
.    …(略)…
;
                                                      シグナルハンドラ
                                                        の設定
$SetConsoleCtrlHandler->Call(
  unpack( 'L', pack( 'P', $x86 ) ), TRUE );
$GenerateConsoleCtrlEvent->Call( CTRL_C_EVENT, 0 );

                                                       Ctrl+C(SIGINT)
                                                       シグナル発生
Perlからx86コードを呼びたい!
Calling x86 code from Perl



     DEMO
第3部 完
第4部
  x86コードからPerlを
       呼びたい!
Calling Perl subs from
       x86 code
x86コードからPerlを呼びたい!
    Calling Perl subs from x86 code

❤これもシグナルハンドラでやってみた
                                             シグナルハンドラ
sub handler { print quot;signal¥nquot;; }
$SIG{INT} = ¥&handler;
                                              ハンドラの設定
my $x86 = quot;…(略) …quot;
. quot;¥x6a¥0quot;            # push 0 Process Group Id
. quot;¥x6a¥0quot;            # push 0 Ctrl-C Event
. quot;¥xb8quot;              # mov eax, addr             シグナルの発生
. $addr{'GenerateConsoleCtrlEvent'}
. quot;¥xff¥xd0quot;          # call eax
. …(略)…
;
$SetConsoleCtrlHandler->Call(                     x86コードの呼出
  unpack( 'L', pack( 'P', $x86 ) ), TRUE );
$GenerateConsoleCtrlEvent->Call( CTRL_BREAK_EVENT, 0 );
x86コードからPerlを呼びたい!




   DEMO
x86コードからPerlを呼びたい!
   Calling Perl subs from x86 code

シグナルを使ったプロセス内通信
InProc communication with signal

❤シグナルを使い分ける
 Separate signals
  ❤Perl → x86 : SIGBREAK (Ctrl-Break)
  ❤x86 → Perl : SIGINT (Ctrl-C)

❤シグナルハンドラ内でシグナルを発生させてる><
 Raise signal in signal handler. X-(
x86コードからPerlを呼びたい!
   Calling Perl subs from x86 code

シグナルを使ったプロセス内通信
InProc communication with signal

Perlさ~ん                       バイナリさ~ん
命
     バ
    シッ 名
    通グド
高

    信ナ
林
哲
さ

     ル
ん
公
認
x86コードからPerlを呼びたい!
    Calling Perl subs from x86 code

それ Win32::API::Callback で
                         できるよ
You can do that with
             Win32::API::Callback


             orz
x86コードからPerlを呼びたい!
Calling Perl subs from x86 code




      DEMO
第4部 完
第5部
まともな使い道!
 Decent use
まともな使い道!
   Decent use
❤stdcall以外のDLL関数も呼び出せる!
 Calling non-stdcall functions
呼出規約     引数の渡し方              引数のクリア

 stdcall 右から左にスタックに格納 関数内
         右から左にスタックに格納 呼び出し側
 cdecl
fastcall レジスタを使用            呼び出し側

❤Win32::API はstdcallのみ
 Win32::API is only for stdcall
まともな使い道!
Decent use



    DEMO
第5部 完
まとめ
❤頑張れば結構なんでもできる!
❤バイナリコード書くの難しい?
 →「迷ったときはテキスト」
❤printfデバッグ万歳!
 print unpack( 'H2 ' x length( $x86 ), $x86 );




                Thanks to
                TAKESAKOさん、kazuhoさん、tokuhiromさん

Mais conteúdo relacionado

Mais procurados

Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
Joseph Scott
 
はじめてのanything-c-source-*
はじめてのanything-c-source-*はじめてのanything-c-source-*
はじめてのanything-c-source-*
Kenichirou Oyama
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
Sean Hess
 
festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...
festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...
festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...
festival ICT 2016
 
Simple php backdoor_by_dk
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dk
Stan Adrian
 
Tong Hop Bai Tap C
Tong Hop Bai Tap CTong Hop Bai Tap C
Tong Hop Bai Tap C
SamQuiDaiBo
 

Mais procurados (20)

Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
S2Flex2
S2Flex2S2Flex2
S2Flex2
 
はじめてのanything-c-source-*
はじめてのanything-c-source-*はじめてのanything-c-source-*
はじめてのanything-c-source-*
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it
 
Algoritma 5 november wiwik p.l
Algoritma 5 november wiwik p.lAlgoritma 5 november wiwik p.l
Algoritma 5 november wiwik p.l
 
Vladimir Vorontsov - Splitting, smuggling and cache poisoning come back
Vladimir Vorontsov - Splitting, smuggling and cache poisoning come backVladimir Vorontsov - Splitting, smuggling and cache poisoning come back
Vladimir Vorontsov - Splitting, smuggling and cache poisoning come back
 
톰캣 #05+a-배치-parallel deployment
톰캣 #05+a-배치-parallel deployment톰캣 #05+a-배치-parallel deployment
톰캣 #05+a-배치-parallel deployment
 
Joy of Six - Discover the Joy of Perl 6
Joy of Six - Discover the Joy of Perl 6Joy of Six - Discover the Joy of Perl 6
Joy of Six - Discover the Joy of Perl 6
 
Wso2 esb-rest-integration
Wso2 esb-rest-integrationWso2 esb-rest-integration
Wso2 esb-rest-integration
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
 
Misha Bilenko @ Microsoft
Misha Bilenko @ MicrosoftMisha Bilenko @ Microsoft
Misha Bilenko @ Microsoft
 
festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...
festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...
festival ICT 2013: Solid as diamond: use ruby in an web application penetrati...
 
Simple php backdoor_by_dk
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dk
 
Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013
 
Agileな開発現場での実践例
Agileな開発現場での実践例Agileな開発現場での実践例
Agileな開発現場での実践例
 
Theme Development and Customization
Theme Development and CustomizationTheme Development and Customization
Theme Development and Customization
 
Using Spectrum Sweeps
Using Spectrum SweepsUsing Spectrum Sweeps
Using Spectrum Sweeps
 
Search videos with youtube api3
Search videos with youtube api3Search videos with youtube api3
Search videos with youtube api3
 
Tong Hop Bai Tap C
Tong Hop Bai Tap CTong Hop Bai Tap C
Tong Hop Bai Tap C
 
Debugging in Clojure: Finding Light in the Darkness using Emacs and Cursive
Debugging in Clojure: Finding Light in the Darkness using Emacs and CursiveDebugging in Clojure: Finding Light in the Darkness using Emacs and Cursive
Debugging in Clojure: Finding Light in the Darkness using Emacs and Cursive
 

Semelhante a WindowsユーザのためのはじめてのPerlプログラミング

Web應用程式以及資安問題的探討
Web應用程式以及資安問題的探討Web應用程式以及資安問題的探討
Web應用程式以及資安問題的探討
Mu Chun Wang
 
事件模型探究
事件模型探究事件模型探究
事件模型探究
ematrix
 
企业级搜索引擎Solr交流
企业级搜索引擎Solr交流企业级搜索引擎Solr交流
企业级搜索引擎Solr交流
chuan liang
 
421 Ch
421 Ch421 Ch
421 Ch
anjaan
 
Ruby on Rails 2.1 What's New Chinese Version
Ruby on Rails 2.1 What's New Chinese VersionRuby on Rails 2.1 What's New Chinese Version
Ruby on Rails 2.1 What's New Chinese Version
Libin Pan
 

Semelhante a WindowsユーザのためのはじめてのPerlプログラミング (20)

Revisited
RevisitedRevisited
Revisited
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port
 
Erlang with Regexp Perl And Port
Erlang with Regexp Perl And PortErlang with Regexp Perl And Port
Erlang with Regexp Perl And Port
 
Shibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼうShibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼう
 
Web應用程式以及資安問題的探討
Web應用程式以及資安問題的探討Web應用程式以及資安問題的探討
Web應用程式以及資安問題的探討
 
XS Japan 2008 Xen Mgmt Japanese
XS Japan 2008 Xen Mgmt JapaneseXS Japan 2008 Xen Mgmt Japanese
XS Japan 2008 Xen Mgmt Japanese
 
S is for Spec
S is for SpecS is for Spec
S is for Spec
 
事件模型探究
事件模型探究事件模型探究
事件模型探究
 
Rails Deployment with NginX
Rails Deployment with NginXRails Deployment with NginX
Rails Deployment with NginX
 
企业级搜索引擎Solr交流
企业级搜索引擎Solr交流企业级搜索引擎Solr交流
企业级搜索引擎Solr交流
 
Performance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScriptPerformance, Games, and Distributed Testing in JavaScript
Performance, Games, and Distributed Testing in JavaScript
 
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Development
 
Speeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorallSpeeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorall
 
421 Ch
421 Ch421 Ch
421 Ch
 
HTML Parsing With Hpricot
HTML Parsing With HpricotHTML Parsing With Hpricot
HTML Parsing With Hpricot
 
Ruby on Rails 2.1 What's New Chinese Version
Ruby on Rails 2.1 What's New Chinese VersionRuby on Rails 2.1 What's New Chinese Version
Ruby on Rails 2.1 What's New Chinese Version
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08
 

Mais de Yosuke HASEGAWA (8)

次世代プラットフォームのセキュリティモデル考察(前編)
次世代プラットフォームのセキュリティモデル考察(前編)次世代プラットフォームのセキュリティモデル考察(前編)
次世代プラットフォームのセキュリティモデル考察(前編)
 
JavaScript難読化読経
JavaScript難読化読経JavaScript難読化読経
JavaScript難読化読経
 
ES6時代におけるWeb開発者とセキュリティ業界の乖離
ES6時代におけるWeb開発者とセキュリティ業界の乖離ES6時代におけるWeb開発者とセキュリティ業界の乖離
ES6時代におけるWeb開発者とセキュリティ業界の乖離
 
他人事ではないWebセキュリティ
他人事ではないWebセキュリティ他人事ではないWebセキュリティ
他人事ではないWebセキュリティ
 
HTML5のセキュリティ もうちょい詳しく- HTML5セキュリティその3 : JavaScript API
HTML5のセキュリティ もうちょい詳しく- HTML5セキュリティその3 : JavaScript APIHTML5のセキュリティ もうちょい詳しく- HTML5セキュリティその3 : JavaScript API
HTML5のセキュリティ もうちょい詳しく- HTML5セキュリティその3 : JavaScript API
 
Bypass SOP, Theft Your Data - XSS Allstars from Japan / OWASP AppSec APAC 2014
Bypass SOP, Theft Your Data - XSS Allstars from Japan / OWASP AppSec APAC 2014Bypass SOP, Theft Your Data - XSS Allstars from Japan / OWASP AppSec APAC 2014
Bypass SOP, Theft Your Data - XSS Allstars from Japan / OWASP AppSec APAC 2014
 
Chrome-eject がこの先生きのこるには
Chrome-eject がこの先生きのこるにはChrome-eject がこの先生きのこるには
Chrome-eject がこの先生きのこるには
 
[デブサミ2012]趣味と実益の脆弱性発見
[デブサミ2012]趣味と実益の脆弱性発見[デブサミ2012]趣味と実益の脆弱性発見
[デブサミ2012]趣味と実益の脆弱性発見
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

WindowsユーザのためのはじめてのPerlプログラミング