{"id":182,"date":"2014-10-14T21:00:39","date_gmt":"2014-10-14T20:00:39","guid":{"rendered":"https:\/\/www.attackdebris.com\/?p=182"},"modified":"2017-06-24T17:48:22","modified_gmt":"2017-06-24T16:48:22","slug":"scriptftf-script-file-transfer-framework","status":"publish","type":"post","link":"https:\/\/www.attackdebris.com\/?p=182","title":{"rendered":"Babel Scripting Framework (babel-sf)"},"content":{"rendered":"<p>The Babel Scripting Framework (babel-sf) is a collection of custom scripts to facilitate useful pentest related functions via scripting languages.<\/p>\n<p>All of the following tools are replicated in the following languages \u2013 PowerShell, Perl, Ruby and Python:<\/p>\n<ol>\n<li>Portscanner<\/li>\n<li>ARPscanner<\/li>\n<li>FTP Client<\/li>\n<li>WGET Client<\/li>\n<li>Bind Metasploit Payload<\/li>\n<li>Reverse Metasploit Payload<\/li>\n<\/ol>\n<p><strong>Why a custom scripting framework?<\/strong><\/p>\n<p>babel-sf has been created for testing minimal installations, locked down and\/or hardened environments e.g.<\/p>\n<ol>\n<li>When the target Operating System has a minimal installation<\/li>\n<li>When the Operating System&#8217;s native tools have been removed<\/li>\n<li>When the Operating System&#8217;s native tools have been locked down via ACLs, Group Policy or AppLocker<\/li>\n<\/ol>\n<p>But crucially, you still have access to one or more scripting languages e.g. Python<\/p>\n<p>Its development was also partially driven by my own needs:<\/p>\n<ol>\n<li>Proof of Concept i.e. to demonstrate why access to scripting languages can be bad!<\/li>\n<li>System Administrator &#8220;Yeah, users have access to [ruby\/perl\/python\/PowerShell], so what?&#8221;<\/li>\n<\/ol>\n<p><strong>But really Why?<\/strong><\/p>\n<p>To solve reoccurring problems encountered during my testing:<\/p>\n<ol>\n<li>Having to write your own code to perform a required task (takes time!)<\/li>\n<li>Having to Google for code to (re)use, tweak and\/or just to get working (takes time!)<\/li>\n<\/ol>\n<p>I expect\u00a0 babel-sf to be used when you don&#8217;t have any tools or Operating System utilities available e.g.<\/p>\n<ol>\n<li>No telnet<\/li>\n<li>No FTP<\/li>\n<li>No wget<\/li>\n<li>No SSH<\/li>\n<li>No netcat, nmap etc. etc.<\/li>\n<\/ol>\n<p>In this scenario you simply download babel-sf\u00a0 onto the target box via a short one liner (in whichever scripting language is available to you).<\/p>\n<p><strong>Aims?<\/strong><\/p>\n<p>babel-sf &#8220;aspires&#8221; to be identical in each scripting language:<\/p>\n<ol>\n<li type=\"_moz\">Identical Usage (switches etc.)<\/li>\n<li type=\"_moz\">Identical Output<\/li>\n<li type=\"_moz\">Offer an identical &#8216;Look and Feel&#8217;<\/li>\n<\/ol>\n<p><strong>Functionality?<\/strong><\/p>\n<p>As it stands, babel-sf provides scripts for the following functions:<\/p>\n<p><strong>1. Portscanner (see examples below)<\/strong><br \/>\nperl:<br \/>\n<strong><a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/perl-portscan.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-248\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/perl-portscan.jpg\" alt=\"perl-portscan\" width=\"802\" height=\"156\" \/><\/a><\/strong><br \/>\npython:<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/portscan-py.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-244\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/portscan-py.jpg\" alt=\"portscan-py\" width=\"839\" height=\"127\" \/><\/a><br \/>\nruby:<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-portscan.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-249\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-portscan.jpg\" alt=\"ruby-portscan\" width=\"822\" height=\"147\" \/><\/a><br \/>\nPowerShell:<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/powershell_portscan.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-250\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/powershell_portscan.jpg\" alt=\"powershell_portscan\" width=\"864\" height=\"103\" \/><\/a><\/p>\n<p><strong>2. Arpscanner (see examples below):<\/strong><br \/>\nperl:<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/perl-arpscan.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-261\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/perl-arpscan.jpg\" alt=\"perl-arpscan\" width=\"460\" height=\"162\" \/><\/a><br \/>\npython:<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/python-arpscan.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-262\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/python-arpscan.jpg\" alt=\"python-arpscan\" width=\"452\" height=\"153\" \/><\/a><br \/>\nruby:<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-arpscan.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-263\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-arpscan.jpg\" alt=\"ruby-arpscan\" width=\"449\" height=\"161\" \/><\/a><br \/>\nPowerShell:<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/powershell-arpscan.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-264\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/powershell-arpscan.jpg\" alt=\"powershell-arpscan\" width=\"452\" height=\"155\" \/><\/a><\/p>\n<p>So you get the idea, replicated tools in multiple scripting languages&#8230;From now on I&#8217;ll just show one example screenshot per utility (but they are all there!)<\/p>\n<p><strong>3. FTP client (crude)<\/strong><br \/>\nruby (example):<br \/>\n<strong><a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-ftp1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-273\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-ftp1.jpg\" alt=\"ruby-ftp\" width=\"744\" height=\"291\" \/><\/a><\/strong><\/p>\n<p><strong>4. WGET client<\/strong><br \/>\nperl (example):<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/perl-wget.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-272\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/perl-wget.jpg\" alt=\"perl-wget\" width=\"679\" height=\"69\" \/><\/a><\/p>\n<p><strong>5. HTTP Server<\/strong><br \/>\nPowerShell (example):<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/powershell-http.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-275\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/powershell-http.jpg\" alt=\"powershell-http\" width=\"598\" height=\"65\" \/><\/a><\/p>\n<p><strong>6. Bind Metasploit Payload<\/strong><br \/>\npython (example):<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/python-msf-bind.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-277\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/python-msf-bind.jpg\" alt=\"python-msf-bind\" width=\"928\" height=\"77\" \/><\/a><\/p>\n<p><strong>7. Reverse Metasploit Payload<\/strong><br \/>\nruby (example):<br \/>\n<a href=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-msf-reverse.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-278\" src=\"https:\/\/www.attackdebris.com\/wp-content\/uploads\/2014\/05\/ruby-msf-reverse.jpg\" alt=\"ruby-msf-reverse\" width=\"840\" height=\"54\" \/><\/a><\/p>\n<p><strong>Initial Download?<\/strong><\/p>\n<p>Assuming that at least one scripting language is supported on the target system, an initial single line script (which provides wget type functionality) will be run to download babel-sf to the target host.<\/p>\n<p>In practice to download babel-sf to our target system we run the relevant script, for our available programming language.\u00a0 This will have to be typed in manually (but thankfully these scripts short and succinct).<\/p>\n<p><strong>Perl:<\/strong><\/p>\n<p>Create &#8216;download.pl&#8217; containing the following code and execute via: &#8216;perl download.pl&#8217;<\/p>\n<pre>use LWP::Simple; mirror('https:\/\/github.com\/attackdebris\/babel-sf\/archive\/master.zip', 'babel-sf.zip');<\/pre>\n<p><strong>Python:<\/strong><\/p>\n<p>Create &#8216;download.py&#8217; containing the following code and execture via: &#8216;python download.py&#8217;<\/p>\n<pre>import urllib; urllib.urlretrieve('https:\/\/github.com\/attackdebris\/babel-sf\/archive\/master.zip', 'babel-sf.zip')<\/pre>\n<p><strong>Ruby:<\/strong><\/p>\n<p>Create &#8216;download.rb&#8217; containing the following code and execture via: &#8216;ruby download.rb&#8217;<\/p>\n<pre>require 'open-uri'; File.open(\"babel-sf.zip\", \"wb\").write(open(\"https:\/\/github.com\/attackdebris\/babel-sf\/archive\/master.zip\", \"rb\").read)<\/pre>\n<p><strong>PowerShell:<\/strong><\/p>\n<p>Create &#8216;download.ps1&#8217; containing the following code and execture via: &#8216;powershell .\\download.ps1&#8217;<\/p>\n<pre>(new-object System.Net.WebClient).Downloadfile(\"https:\/\/github.com\/attackdebris\/babel-sf\/archive\/master.zip\",\"babel-sf.zip\")<\/pre>\n<p>Obviously, if you were located on a closed network you would download from your own host, rather than from github.<\/p>\n<p><strong>Script Uniformity?<\/strong><\/p>\n<p>The scripts offer uniform functionality to a point, some exceptions are:<\/p>\n<p><strong>Ruby has a socket limit (approx 1024):<\/strong>\u00a0 This limits the maximum number of ports that can be scanned at once<\/p>\n<p><strong>I had to be flexible with the type of metasploit shells included:<\/strong>\u00a0 Whilst, bind and reverse shells are included for each scripting language, one language may provide tcp_shells whlilst another may provide meterpreter shells<\/p>\n<p><strong>Whilst the underlying functionality is similar for all of the different HTTP servers:<\/strong> It proved tricky getting HTTP servers to provide a uniform look\/feel:<\/p>\n<p><strong>Arpscanner usage varies a little between languages: <\/strong>The interface switch (e.g. eth0) is not currently supported in all languages<\/p>\n<p><strong>Confessions!<\/strong><\/p>\n<ol>\n<li>I&#8217;m not a coder (if you are a coder, look away now!)<\/li>\n<li>Coding in 4 different languages at the same time is foolhardy!<\/li>\n<li>Bugs \/ Errors abound<\/li>\n<li>If you don&#8217;t like certain aspects, contribute! Make them better!<\/li>\n<\/ol>\n<p><strong>Testing!<\/strong><\/p>\n<ol>\n<li>Only limited testing has been conducted<\/li>\n<li>Further testing, testing, testing is required e.g. What versions of Perl, Python, Ruby and PowerShell do the scripts run on?<\/li>\n<\/ol>\n<p>babel-sf has been tested on the following target Operating Systems:<\/p>\n<p>Perl, Python and Ruby (Currently only targeting Nix systems)<\/p>\n<ol>\n<li>Ubuntu 12.04<\/li>\n<li>Debian &#8220;wheezy&#8221;<\/li>\n<\/ol>\n<p>PowerShell (Windows)<\/p>\n<ol>\n<li>Created on and tested in PowerShell version 2.0 (Windows 7)<\/li>\n<\/ol>\n<p><strong>Future Additions?<\/strong><\/p>\n<p>Addition of further scripting languages:<\/p>\n<ol>\n<li>PHP<\/li>\n<li>VBScript<\/li>\n<li>Java<\/li>\n<li>More?<\/li>\n<\/ol>\n<p><strong>Links:<\/strong><br \/>\nGithub &#8211; <a title=\"https:\/\/github.com\/attackdebris\/babel-sf\/\" href=\"https:\/\/github.com\/attackdebris\/babel-sf\/\">https:\/\/github.com\/attackdebris\/babel-sf\/<\/a><br \/>\nBlog &#8211; <a title=\"https:\/\/www.attackdebris.com\/?p=182\" href=\"https:\/\/www.attackdebris.com\/?p=182\">https:\/\/www.attackdebris.com\/?p=182<\/a><\/p>\n<p>Babel-sf is not wholly new code by any means; large snipets, small snipets and great ideas have been borrowed from many other open source repositories (hopefully, I&#8217;ve remembered to reference them all!):<\/p>\n<p><strong>References:<\/strong><br \/>\n<a title=\" http:\/\/pentestmonkey.net\/cheat-sheet\/shells\/reverse-shell-cheat-sheet\" href=\"%20http:\/\/pentestmonkey.net\/cheat-sheet\/shells\/reverse-shell-cheat-sheet\"> http:\/\/pentestmonkey.net\/cheat-sheet\/shells\/reverse-shell-cheat-sheet<\/a><br \/>\n<a title=\"http:\/\/www.phillips321.co.uk\/2013\/10\/22\/one-line-python-meterpreter-reverse-shell\/\" href=\"http:\/\/www.phillips321.co.uk\/2013\/10\/22\/one-line-python-meterpreter-reverse-shell\/\">http:\/\/www.phillips321.co.uk\/2013\/10\/22\/one-line-python-meterpreter-reverse-shell\/<\/a><br \/>\n<a title=\"http:\/\/obscuresecurity.blogspot.co.uk\/2014\/05\/dirty-powershell-webserver\" href=\"http:\/\/obscuresecurity.blogspot.co.uk\/2014\/05\/dirty-powershell-webserver\">http:\/\/obscuresecurity.blogspot.co.uk\/2014\/05\/dirty-powershell-webserver<\/a><br \/>\n<a title=\"http:\/\/gist.github.com\/wagnerandrade\/5424431\" href=\"http:\/\/gist.github.com\/wagnerandrade\/5424431\">http:\/\/gist.github.com\/wagnerandrade\/5424431<\/a><br \/>\n<a title=\"http:\/\/hacknotes.wikidot.com\/useful-scripts\" href=\"http:\/\/hacknotes.wikidot.com\/useful-scripts\">http:\/\/hacknotes.wikidot.com\/useful-scripts<\/a><br \/>\n<a title=\"http:\/\/www.jnthn.net\/perlportscanner.shtml\" href=\"http:\/\/www.jnthn.net\/perlportscanner.shtml\">http:\/\/www.jnthn.net\/perlportscanner.shtml<\/a><br \/>\n<a title=\"http:\/\/search.cpan.org\/~ingy\/IO-All\/lib\/IO\/All.pod\" href=\"http:\/\/search.cpan.org\/~ingy\/IO-All\/lib\/IO\/All.pod\">http:\/\/search.cpan.org\/~ingy\/IO-All\/lib\/IO\/All.pod<\/a><br \/>\n<a title=\"https:\/\/docs.python.org\/2\/library\/simplehttpserver\" href=\"https:\/\/docs.python.org\/2\/library\/simplehttpserver\">https:\/\/docs.python.org\/2\/library\/simplehttpserver<\/a><br \/>\n<a title=\"http:\/\/stackoverflow.com\/users\/464744\/blender\" href=\"http:\/\/stackoverflow.com\/users\/464744\/blender\">http:\/\/stackoverflow.com\/users\/464744\/blender<\/a><br \/>\n<a title=\"http:\/\/www.ruby-doc.org\/stdlib-2.0\/libdoc\/webrick\/rdoc\/WEBrick\" href=\"http:\/\/www.ruby-doc.org\/stdlib-2.0\/libdoc\/webrick\/rdoc\/WEBrick\">http:\/\/www.ruby-doc.org\/stdlib-2.0\/libdoc\/webrick\/rdoc\/WEBrick<\/a><br \/>\n<a title=\"http:\/\/www.rapid7.com\/db\/modules\/payload\/ruby\/shell_reverse_tcp\" href=\"http:\/\/www.rapid7.com\/db\/modules\/payload\/ruby\/shell_reverse_tcp\">http:\/\/www.rapid7.com\/db\/modules\/payload\/ruby\/shell_reverse_tcp<\/a><br \/>\n<a title=\"http:\/\/gist.github.com\/jstorimer\/3522068\" href=\"http:\/\/gist.github.com\/jstorimer\/3522068\">http:\/\/gist.github.com\/jstorimer\/3522068<\/a><br \/>\n<a title=\"Coding for penetration testers (Syngress Press)\" href=\"http:\/\/www.amazon.co.uk\/Coding-Penetration-Testers-Building-Better\/dp\/1597497290\">Coding for penetration testers (Syngress Press)<\/a><br \/>\n<a title=\"http:\/\/snipplr.com\/view\/46170\/\" href=\"http:\/\/snipplr.com\/view\/46170\/\">http:\/\/snipplr.com\/view\/46170\/<\/a><br \/>\n<a title=\"http:\/\/code.activestate.com\/recipes\/439094-get-the-ip-address-associated-with-a-network-inter\/\" href=\"http:\/\/code.activestate.com\/recipes\/439094-get-the-ip-address-associated-with-a-network-inter\/\">http:\/\/code.activestate.com\/recipes\/439094-get-the-ip-address-associated-with-a-network-inter\/<\/a><br \/>\n<a title=\"http:\/\/ijdc.blogspot.co.uk\/2011\/12\/powershell-script-to-get-mac-address\" href=\"http:\/\/ijdc.blogspot.co.uk\/2011\/12\/powershell-script-to-get-mac-address\">http:\/\/ijdc.blogspot.co.uk\/2011\/12\/powershell-script-to-get-mac-address<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Babel Scripting Framework (babel-sf) is a collection of custom scripts to facilitate useful pentest related functions via scripting languages. All of the following tools are replicated in the following languages \u2013 PowerShell, Perl, Ruby and Python: Portscanner ARPscanner FTP Client WGET Client Bind Metasploit Payload Reverse Metasploit Payload Why a custom scripting framework? babel-sf &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/www.attackdebris.com\/?p=182\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-182","post","type-post","status-publish","format-standard","hentry","category-tools","item-wrap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3MDvd-2W","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts\/182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=182"}],"version-history":[{"count":68,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts\/182\/revisions"}],"predecessor-version":[{"id":360,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=\/wp\/v2\/posts\/182\/revisions\/360"}],"wp:attachment":[{"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.attackdebris.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}