您好,登錄后才能下訂單哦!
怎么在AIX和Power架構上運行Metasploit Framework,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
我已在我的筆記本電腦上使用qemu-system-ppc64完成了所有這些工作,它非常適合在真正的硬件上進行tinkering(意為探究和動手體驗)和測試。另外,請確保你為qemu模擬處理器分配至少4 GB的內存,否則你將無法運行metasploit(它會一直嘗試加載)這是我的qemu加載器腳本。
附:對于新的qemu-system-ppc64版本和AIX 7.2可能會存在一些問題。我使用的版本可以正常順利的工作,因此這里我將其命名為qemu-system-ppc64-old
QEMU模擬器版本為3.0.50 (v3.0.0-614-g19b599f766-dirty)
./qemu-system-ppc64-old -cpu POWER8 -machine pseries -m 4096 -serial stdio -drive file=disk.img,if=none,id=drive-virtio-disk0 -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=drive-virtio-disk0 -cdrom aix.iso -prom-env boot-command='boot disk: ' -net nic -net tap -display vnc=:1
首先,我們需要安裝一些依賴項。我將通過yum從Aixtoolbox public repo中包含我已安裝在系統中的所有RPM。
AIX-rpm SDL SDL-devel SDL_mixer SDL_ttf SDL_ttf-devel audiofile audiofile-devel autoconf automake bash bzip2 bzip2-devel ca-certificates cmake coreutils cups cups-libs curl cyrus-sasl db dbus esound esound-devel expat expat-devel expect flac fontconfig fontconfig-devel freetype2 freetype2-devel gcc gcc-c++ gcc-cpp gcc-go gdbm gdbm-devel gettext gettext-devel glib glib-devel glib2 glib2-devel gmp gmp-devel gnutls grep gtk+ info less libXft libXft-devel libXrandr libXrender libXrender-devel libffi libffi-devel libgcc libgcrypt libgcrypt-devel libgo libgo-devel libgpg-error libgpg-error-devel libiconv libjpeg libmikmod libmpc libogg libogg-devel libpcap libpcap-devel libpng libpng-devel libssh3 libssh3-devel libstdc++ libstdc++-devel libtasn1 libtool libvorbis libvorbis-devel libxml2 libxml2-devel libxml2-python libxslt libxslt-devel lua m4 mpfr ncurses ncurses-devel nettle nmap openldap p11-kit patch pcre pcre-devel perl pkg-config postgresql postgresql-devel postgresql-libs pth pysqlite python python-cryptography python-devel python-iniparse python-passlib python-pyasn1 python-pycurl python-six python-tools python-urlgrabber python3 readline readline-devel renderproto rsync sed smpeg smpeg-libs sqlite sqlite-devel tar tcl tcsh tightvnc-server tk unzip wget xz xz-devel xz-libs yum yum-metadata-parser zlib zlib-devel
由于來自https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/ruby/的ruby-2.5.1和ruby-devel-2.5.1 RPM在編譯Metasploit所依賴的gem時無法正常工作,因此我選擇在AIX上從源碼構建Ruby。這并不難(我們將安裝到 /usr/local以和/opt/freeware分開)。
在本例中,我使用Ruby 2.5.1版本,但你也可以使用2.5.5或2.6.3版效果是一樣的。
$ wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz $ tar -zxvf ruby-2.5.1.tar.gz $ cd ruby-2.5.1 $ ./configure $ make $ su - # make install
一旦我們安裝了Ruby(確保在你的配置文件中已包含/usr/local),我們就可以繼續從git下載Metasploit快照。我之所以選擇獲取ZIP快照,是因為它在ppc64模擬器下速度會更快。
$ wget https://github.com/rapid7/metasploit-framework/archive/master.zip $ unzip master.zip $ cd metasploit-framework-master
下一步是在metasploit目錄中運行bunlde install,但我們現在將跳過此步驟,因為我們需要在本地自定義2個gem,并在AIX 7.2上編譯和構建它們。
nokogiri-1.10.3.gem bcrypt-3.1.13
由于nokogiri不會在AIX上構建,因為缺少vasprintf()函數,它不是POSIX接口,并且不在AIX中的C庫中,如果不修改構建過程gem將構建和編譯,但最終庫將不起作用,并出現以下錯誤:
bash-5.0# /usr/local/bin/gem install nokogiri-1.10.3.gem Building native extensions. This could take a while... Successfully installed nokogiri-1.10.3 Parsing documentation for nokogiri-1.10.3 Done installing documentation for nokogiri after 49 seconds 1 gem installed bash-5.0# /usr/local/bin/nokogiri Traceback (most recent call last): 8: from /usr/local/bin/nokogiri:23:in <main>' 7: from /usr/local/bin/nokogiri:23:in load' 6: from /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.3/bin/nokogiri:6:in <top (required)>' 5: from /usr/local/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in require' 4: from /usr/local/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in require' 3: from /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.3/lib/nokogiri.rb:28:in <top (required)>' 2: from /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.3/lib/nokogiri.rb:32:in rescue in <top (required)>' 1: from /usr/local/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in require' /usr/local/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': load failed - /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.3/lib/nokogiri/nokogir.so. Please issue below command for detailed reasons: (LoadError) /usr/sbin/execerror ruby "(ld 3 1 vasprintf /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.3/lib/nokogiri/nokogiri.so"
我們可以通過運行命令來檢查錯誤的詳細信息:
bash-5.0# /usr/sbin/execerror ruby "(ld 3 1 vasprintf /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.3/lib/nokogiri/nokogiri.so" exec(): 0509-036 Cannot load program ruby because of the following errors: rtld: 0712-001 Symbol vasprintf was referenced from module /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.10.3/lib/nokogiri/nokogiri.so(), but a runtime definition of the symbol was not found.
可以看到缺少vasprintf符號并被調用。
讓我們為Ruby gem創建一個工作目錄并下載nokogiri。
$ mkdir GEMS $ cd GEMS $ gem fetch nokogiri Fetching: nokogiri-1.10.3.gem (100%) Downloaded nokogiri-1.10.3 $ gem spec nokogiri-1.10.3.gem --ruby > nokogiri.gemspec $ gem unpack nokogiri-1.10.3.gem Unpacked gem: '/home/root/LOCAL-GEMS/TT/nokogiri-1.10.3' $ mv nokogiri.gemspec nokogiri-1.10.3 $ cd nokogiri-1.10.3 $ cd ext/nokogiri
現在,我們將修改extconf.rb文件以包含構建過程,并在AIX上創建一個工作的nokogiri.so共享庫并定位到nix? $CFLAGS <<
修改為:
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF "
保存并返回到構建nokogiri gem
$ cd ../.. $ gem build nokogiri.gemspec WARNING: ports/archives/libxml2-2.9.9.tar.gz is not world-readable WARNING: ports/archives/libxslt-1.1.33.tar.gz is not world-readable WARNING: no homepage specified WARNING: pessimistic dependency on mini_portile2 (~> 2.4.0) may be overly strict if mini_portile2 is semantically versioned, use: add_runtime_dependency 'mini_portile2', '~> 2.4', '>= 2.4.0' WARNING: pessimistic dependency on racc (~> 1.4.14, development) may be overly strict if racc is semantically versioned, use: add_development_dependency 'racc', '~> 1.4', '>= 1.4.14' WARNING: pessimistic dependency on rake-compiler (~> 1.0.3, development) may be overly strict if rake-compiler is semantically versioned, use: add_development_dependency 'rake-compiler', '~> 1.0', '>= 1.0.3' WARNING: pessimistic dependency on rexical (~> 1.0.5, development) may be overly strict if rexical is semantically versioned, use: add_development_dependency 'rexical', '~> 1.0', '>= 1.0.5' WARNING: See http://guides.rubygems.org/specification-reference/ for help Successfully built RubyGem Name: nokogiri Version: 1.10.3 File: nokogiri-1.10.3.gem $ su # gem install nokogiri-1.10.3.gem
經過一段時間后最終它將被構建(在qemu下它的速度很慢)我們可以通過執行gem本身來檢查最終的nokogiri gem是否真的已經工作。
# gem install bcrypt Fetching: bcrypt-3.1.13.gem (100%) Building native extensions. This could take a while... ERROR: Error installing bcrypt: ERROR: Failed to build gem native extension. current directory: /usr/local/lib/ruby/gems/2.5.0/gems/bcrypt-3.1.13/ext/mri /usr/local/bin/ruby -r ./siteconf20190624-6029732-1f0poah.rb extconf.rb creating Makefile current directory: /usr/local/lib/ruby/gems/2.5.0/gems/bcrypt-3.1.13/ext/mri make "DESTDIR=" clean current directory: /usr/local/lib/ruby/gems/2.5.0/gems/bcrypt-3.1.13/ext/mri make "DESTDIR=" compiling bcrypt_ext.c compiling crypt_blowfish.c compiling crypt_gensalt.c compiling wrapper.c linking shared-object bcrypt_ext.so gcc: error: x86.o: No such file or directory make: 1254-004 The error code from the last command is 1. Stop. make failed, exit code 2 Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/bcrypt-3.1.13 for inspection. Results logged to /usr/local/lib/ruby/gems/2.5.0/extensions/powerpc-aix-7/2.5.0-static/bcrypt-3.1.13/gem_make.out
在ppc64 AIX平臺上使用x86.o對象文件也出現了一些問題...但修復起來也很容易,你只需重復上面的操作獲取gem并修改構建過程就行了。
$ gem fetch bcrypt Fetching: bcrypt-3.1.13.gem (100%) Downloaded bcrypt-3.1.13 $ gem spec bcrypt-3.1.13.gem --ruby > bcrypt.gemspec $ gem unpack bcrypt-3.1.13.gem $ mv bcrypt.gemspec bcrypt-3.1.13 $ cd bcrypt-3.1.13 $ cd ext/mri
讓我們再次編輯extconf.rb文件并刪除x86引用
刪除x86.o保存并重新生成gem
$ cd ../.. $ gem build bcrypt.gemspec WARNING: open-ended dependency on rspec (>= 3, development) is not recommended if rspec is semantically versioned, use: add_development_dependency 'rspec', '~> 3' WARNING: See http://guides.rubygems.org/specification-reference/ for help Successfully built RubyGem Name: bcrypt Version: 3.1.13 File: bcrypt-3.1.13.gem $ su # gem install bcrypt-3.1.13.gem Building native extensions. This could take a while... Successfully installed bcrypt-3.1.13 Parsing documentation for bcrypt-3.1.13 Installing ri documentation for bcrypt-3.1.13 Done installing documentation for bcrypt after 26 seconds 1 gem installed
現在,我們應該已將所有Metasploit框架所需的缺失gem都安裝上了,所以只需從metasploit根目錄運行bundle install即可
$ cd metasploit-framework-master $ bundle install
因為這需要一些時間,因此你可以泡杯咖啡/茶慢慢品嘗。在這個時間里我打算去外面轉轉。
現在,你是否已準備好在AIX 7.2上運行Metasploit框架了?我想說是的!
我們可以運行./msfconsole(這在qemu下可能需要一些時間)
甚至可以對up2date windows 10 1903(10.0.18362.175)執行一些實時測試,并在運行時繞過MS Defender;)
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。