SlideShare a Scribd company logo
1 of 20
Perl Basics for Pentesters
Part 1
Sanjeev Jaiswal (Jassi)
Perl Programmer and Security Enthusiast
#nullhyd
Part 1
Perl Introduction Perl data Types
Control structures and loops Special Variable
Functions to memorize File handling
Part 2
Regular Expression Modules to know
Perl Helpers Scripts for Pentesting
Perl codes basic examples Future Scope
Demo of tools like dnsenum, fierce, nikto, sqlninja
What we will cover
Perl Fundamentals
• When you refer a programming language say it Perl
• When you refer a script , let’s say perl
• But never ever say PERL, use perl or Perl
Perl mongers and Larry Wall don’t like it ;-)
Perl has some backronyms though
Practical Extraction and Report Language, or
Pathologically Eclectic Rubbish Lister.
And its Perl not Pearl
Perl or perl or PERL?
• Try perl -v to check if it’s installed or not
Unix/Linux
• Run curl -L http://xrl.us/installperlnix | bash in terminal
OSX
• Install command line toll Xcode
• Run curl -L http://xrl.us/installperlnix | bash in terminal
Windows
• install strawberry perl or activestate perl
Then install cpan App::cpanminus to install perl modules easily in future
Installing perl
• perl <perl_program>
• chmod 755 and execute ./<perl_program>
Let’s try something more on CLI
• perl –d <perl_program> #Diagonise more
• perl –c <perl_program> #check if syntax is ok
• perl -e 'print "perl one-linern";'
• perl one-liner examples (palindrome, inplace-editing)
Executing perl program
•shebang i.e #!
•print, say
•#comment
•$calar, @rray, %ash
•Comparison operators (> or gt <= or le)
•Reference in Perl
•%INC and @INC
Who’s who in Perl ;)
#!/usr/bin/perl #Shebang starts with #!
use strict;
use warnings;
# It's a comment and its just the basic
my $name = "Sanjeev Jaiswal"; #scalar
my $id = 10; # scalar
my $sal = 100.98; #scalar
my @name = ("Sanjeev", "Jaiswal"); #array
my %hash = ('fname'=>'Sanjeev', 'lname', 'Jaiswal'); #hash
print "$id, $name[0], $hash{'lname}n";
print "$namen" if ( $id < 100 );
Basic Example in Perl ;)
Loop Control
•if, if else, if elsif else
•for, foreach
•while, do while
•next, unless, last
•return, exit
Loop and control structures
while(<>){
next if /^d+/;
last if /^W/;
print $_;
}
print $_ foreach(1 .. 100);
print if(10 <= 10.0);
if($name eq 'sanjeev'){
print "$namen";
} elsif ($id >70){
print "$idn";
} else {
print "not matchedn";
}
Loop and control structures
Functions to memorize
•shift , push and chomp
•sort and reverse
•exec, system and eval
•warn, die
•join and split
•keys, values, each
•exists, defined, delete, unlink
Minimal functions you should know
• chomp (my $u_input = <STDIN>); #chomps the user input
• my $f_elem = shift @array; # assign first element of an array
• push @arr, $elem; # Adding $elem at the last of @arr
• @sorted_num = sort {$a <=> $b} @unsorted_num; #sort integer array
• @reverse_sort = sort {$b <=> $a} @unsorted_num; #reverse sort
• @reverse_sort = reverse sort @unsorted_arr # reverse sort of string array or
• @reverse_sort = sort {$b cmp $a} @unsorted_arr
• warn "Very highn" if($num > 10);
• die "Very lown" if($num < 2);
• system("ls -la", "dir" )
• exec("/bin/cat", "/home.txt");
• `ls -la`; #avoid backtick if possible
• join(/s/ , @array);
• split(/s/, $string);
Minimal examples ;)
Perl File Handlers
•open(), close()
•>, >>, <
•+>, +>>, +<
•File testing -e, -f, -d, -s, -m etc.
•opendir, closedir, readdir
Manipulate file handling
open(FH, "<", "filename") or die "can't open: $!n";
# > for write and >> for append
while ( defined(my $line = <FH>) ) { do something .. }
close(FH);
open(LS, "<", "ls -la|"); # use instead of ``
open(FIND, "find . -type f -name dns_info.pl |-"); #better than previous command
do something if -e $file; # -e means exists, -f is for file and -d for directory
do something if -s >0; #-s is for size and -m means modified
$dir = "/home/sanjeev/";
opendir ( DIR, $dir ) || die "Error in opening directory $dirn";
while( ($file = readdir(DIR))){
next if $file =~ m/.{1,2}/;
print("$filen") if -f $file;
}
closedir(DIR);
File Handling examples
Perl Special Variables
• $0 – name of perl script being executed
• $^O – O.S.
• $! – current value of errno in scalar and string in list context
• $@ - error message from the last eval, do-FILE, or require command
• $_ - default input and search pattern space
• @_ - arguments passed to the given subroutine
• $$ - process number of the running program
• $? – status returned by the last pipe close, back tick or system command
Most used special variables
Questions

More Related Content

What's hot

BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationWorkhorse Computing
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10acme
 
Manifests of Future Past
Manifests of Future PastManifests of Future Past
Manifests of Future PastPuppet
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPatrick Allaert
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)Nikita Popov
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6 brian d foy
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationWorkhorse Computing
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Puppet
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Workhorse Computing
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3Matthew Turland
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappersPositive Hack Days
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Workhorse Computing
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 

What's hot (20)

BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
Manifests of Future Past
Manifests of Future PastManifests of Future Past
Manifests of Future Past
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic Interpolation
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
 
New SPL Features in PHP 5.3
New SPL Features in PHP 5.3New SPL Features in PHP 5.3
New SPL Features in PHP 5.3
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 

Similar to Perl Basics for Pentesters Part 1

Similar to Perl Basics for Pentesters Part 1 (20)

Perl Scripting
Perl ScriptingPerl Scripting
Perl Scripting
 
IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable Perl
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Practical approach to perl day1
Practical approach to perl day1Practical approach to perl day1
Practical approach to perl day1
 
You Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager NeedsYou Can Do It! Start Using Perl to Handle Your Voyager Needs
You Can Do It! Start Using Perl to Handle Your Voyager Needs
 
Perl bhargav
Perl bhargavPerl bhargav
Perl bhargav
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
php
phpphp
php
 
Syntax
SyntaxSyntax
Syntax
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Learn perl in amc square learning
Learn perl in amc square learningLearn perl in amc square learning
Learn perl in amc square learning
 
The Essential Perl Hacker's Toolkit
The Essential Perl Hacker's ToolkitThe Essential Perl Hacker's Toolkit
The Essential Perl Hacker's Toolkit
 

More from n|u - The Open Security Community

Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...n|u - The Open Security Community
 

More from n|u - The Open Security Community (20)

Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)
 
Osint primer
Osint primerOsint primer
Osint primer
 
SSRF exploit the trust relationship
SSRF exploit the trust relationshipSSRF exploit the trust relationship
SSRF exploit the trust relationship
 
Nmap basics
Nmap basicsNmap basics
Nmap basics
 
Metasploit primary
Metasploit primaryMetasploit primary
Metasploit primary
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
Introduction to TLS 1.3
Introduction to TLS 1.3Introduction to TLS 1.3
Introduction to TLS 1.3
 
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
 
Talking About SSRF,CRLF
Talking About SSRF,CRLFTalking About SSRF,CRLF
Talking About SSRF,CRLF
 
Building active directory lab for red teaming
Building active directory lab for red teamingBuilding active directory lab for red teaming
Building active directory lab for red teaming
 
Owning a company through their logs
Owning a company through their logsOwning a company through their logs
Owning a company through their logs
 
Introduction to shodan
Introduction to shodanIntroduction to shodan
Introduction to shodan
 
Cloud security
Cloud security Cloud security
Cloud security
 
Detecting persistence in windows
Detecting persistence in windowsDetecting persistence in windows
Detecting persistence in windows
 
Frida - Objection Tool Usage
Frida - Objection Tool UsageFrida - Objection Tool Usage
Frida - Objection Tool Usage
 
OSQuery - Monitoring System Process
OSQuery - Monitoring System ProcessOSQuery - Monitoring System Process
OSQuery - Monitoring System Process
 
DevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -SecurityDevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -Security
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
 
Linux for hackers
Linux for hackersLinux for hackers
Linux for hackers
 
Android Pentesting
Android PentestingAndroid Pentesting
Android Pentesting
 

Recently uploaded

AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls DubaiEscorts Call Girls
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Standkumarajju5765
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...SUHANI PANDEY
 

Recently uploaded (20)

AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 

Perl Basics for Pentesters Part 1

  • 1. Perl Basics for Pentesters Part 1 Sanjeev Jaiswal (Jassi) Perl Programmer and Security Enthusiast #nullhyd
  • 2. Part 1 Perl Introduction Perl data Types Control structures and loops Special Variable Functions to memorize File handling Part 2 Regular Expression Modules to know Perl Helpers Scripts for Pentesting Perl codes basic examples Future Scope Demo of tools like dnsenum, fierce, nikto, sqlninja What we will cover
  • 4. • When you refer a programming language say it Perl • When you refer a script , let’s say perl • But never ever say PERL, use perl or Perl Perl mongers and Larry Wall don’t like it ;-) Perl has some backronyms though Practical Extraction and Report Language, or Pathologically Eclectic Rubbish Lister. And its Perl not Pearl Perl or perl or PERL?
  • 5. • Try perl -v to check if it’s installed or not Unix/Linux • Run curl -L http://xrl.us/installperlnix | bash in terminal OSX • Install command line toll Xcode • Run curl -L http://xrl.us/installperlnix | bash in terminal Windows • install strawberry perl or activestate perl Then install cpan App::cpanminus to install perl modules easily in future Installing perl
  • 6. • perl <perl_program> • chmod 755 and execute ./<perl_program> Let’s try something more on CLI • perl –d <perl_program> #Diagonise more • perl –c <perl_program> #check if syntax is ok • perl -e 'print "perl one-linern";' • perl one-liner examples (palindrome, inplace-editing) Executing perl program
  • 7. •shebang i.e #! •print, say •#comment •$calar, @rray, %ash •Comparison operators (> or gt <= or le) •Reference in Perl •%INC and @INC Who’s who in Perl ;)
  • 8. #!/usr/bin/perl #Shebang starts with #! use strict; use warnings; # It's a comment and its just the basic my $name = "Sanjeev Jaiswal"; #scalar my $id = 10; # scalar my $sal = 100.98; #scalar my @name = ("Sanjeev", "Jaiswal"); #array my %hash = ('fname'=>'Sanjeev', 'lname', 'Jaiswal'); #hash print "$id, $name[0], $hash{'lname}n"; print "$namen" if ( $id < 100 ); Basic Example in Perl ;)
  • 10. •if, if else, if elsif else •for, foreach •while, do while •next, unless, last •return, exit Loop and control structures
  • 11. while(<>){ next if /^d+/; last if /^W/; print $_; } print $_ foreach(1 .. 100); print if(10 <= 10.0); if($name eq 'sanjeev'){ print "$namen"; } elsif ($id >70){ print "$idn"; } else { print "not matchedn"; } Loop and control structures
  • 13. •shift , push and chomp •sort and reverse •exec, system and eval •warn, die •join and split •keys, values, each •exists, defined, delete, unlink Minimal functions you should know
  • 14. • chomp (my $u_input = <STDIN>); #chomps the user input • my $f_elem = shift @array; # assign first element of an array • push @arr, $elem; # Adding $elem at the last of @arr • @sorted_num = sort {$a <=> $b} @unsorted_num; #sort integer array • @reverse_sort = sort {$b <=> $a} @unsorted_num; #reverse sort • @reverse_sort = reverse sort @unsorted_arr # reverse sort of string array or • @reverse_sort = sort {$b cmp $a} @unsorted_arr • warn "Very highn" if($num > 10); • die "Very lown" if($num < 2); • system("ls -la", "dir" ) • exec("/bin/cat", "/home.txt"); • `ls -la`; #avoid backtick if possible • join(/s/ , @array); • split(/s/, $string); Minimal examples ;)
  • 16. •open(), close() •>, >>, < •+>, +>>, +< •File testing -e, -f, -d, -s, -m etc. •opendir, closedir, readdir Manipulate file handling
  • 17. open(FH, "<", "filename") or die "can't open: $!n"; # > for write and >> for append while ( defined(my $line = <FH>) ) { do something .. } close(FH); open(LS, "<", "ls -la|"); # use instead of `` open(FIND, "find . -type f -name dns_info.pl |-"); #better than previous command do something if -e $file; # -e means exists, -f is for file and -d for directory do something if -s >0; #-s is for size and -m means modified $dir = "/home/sanjeev/"; opendir ( DIR, $dir ) || die "Error in opening directory $dirn"; while( ($file = readdir(DIR))){ next if $file =~ m/.{1,2}/; print("$filen") if -f $file; } closedir(DIR); File Handling examples
  • 19. • $0 – name of perl script being executed • $^O – O.S. • $! – current value of errno in scalar and string in list context • $@ - error message from the last eval, do-FILE, or require command • $_ - default input and search pattern space • @_ - arguments passed to the given subroutine • $$ - process number of the running program • $? – status returned by the last pipe close, back tick or system command Most used special variables