Praedasploit xerox ldap

This PR is the Praedasploit Xerox workcentre 5735 LDAP credential extractor. This module performs an LDAP pass-back-attack against the Xerox printer and captures the LDAP credentials configured on the printer. 

Below is an example of the options for for the module:
![xerox_ldap_options](https://cloud.githubusercontent.com/assets/3900108/4799414/43ed8886-5e1c-11e4-9b87-49a8dd4a013a.png)
 
Testing Steps:
Set NewLDAPServer to the IP address of the system running Metasploit
Set RHOST to the IP address of the Xerox printer
Set RPORT to the XEROX WorkCentre web management interface
Set SRVHOST to the IP address to listen on. This is usually the system running Metasploit 
set SRVPORT to the local port to listen on. This is the port the Xerox printer will connect back on.

Now run the module. The following image is an example of the module running on a test Xerox workcentre 5735 printer. 

![xerox_ldap_capture](https://cloud.githubusercontent.com/assets/3900108/4799872/5a69e2fe-5e20-11e4-8a10-96e759601850.png)

Any questions please let me know. 
For readability, I would do something like this:

```ruby
post_vars = {
'nameSchema'=>'givenName',
'emailSchema'=>'mail',
'phoneSchema'=>'telephoneNumber',
'postalSchema'=>'postalAddress',
'mailstopSchema'=>'l',
'citySchema'=>'physicalDeliveryOfficeName',
'stateSchema'=>'st',
'zipCodeSchema'=>'postalcode',
'countrySchema'=>'co',
'faxSchema'=>'facsimileTelephoneNumber',
'homeSchema'=>'homeDirectory',
'memberSchema'=>'memberOf',
'uidSchema'=>'uid',
'ldapSearchName'=>'test',
'ldapServerIndex'=>'default',
'_fun_function'=>'HTTP_LDAP_Search_fn',
'NextPage'=>'%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig'
}

post_string = []
post_vars.each_pair {|k, v| post_string << "#{k}=#{v}" }
post_string *= '&'
```

Here's a test:

```
$ irb
1.9.3-p547 :001 > temp = "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :002 > 
1.9.3-p547 :003 >   
1.9.3-p547 :004 >   post_vars = {
1.9.3-p547 :005 >     'nameSchema'=>'givenName',
1.9.3-p547 :006 >     'emailSchema'=>'mail',
1.9.3-p547 :007 >     'phoneSchema'=>'telephoneNumber',
1.9.3-p547 :008 >     'postalSchema'=>'postalAddress',
1.9.3-p547 :009 >     'mailstopSchema'=>'l',
1.9.3-p547 :010 >     'citySchema'=>'physicalDeliveryOfficeName',
1.9.3-p547 :011 >     'stateSchema'=>'st',
1.9.3-p547 :012 >     'zipCodeSchema'=>'postalcode',
1.9.3-p547 :013 >     'countrySchema'=>'co',
1.9.3-p547 :014 >     'faxSchema'=>'facsimileTelephoneNumber',
1.9.3-p547 :015 >     'homeSchema'=>'homeDirectory',
1.9.3-p547 :016 >     'memberSchema'=>'memberOf',
1.9.3-p547 :017 >     'uidSchema'=>'uid',
1.9.3-p547 :018 >     'ldapSearchName'=>'test',
1.9.3-p547 :019 >     'ldapServerIndex'=>'default',
1.9.3-p547 :020 >     '_fun_function'=>'HTTP_LDAP_Search_fn',
1.9.3-p547 :021 >     'NextPage'=>'%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig'
1.9.3-p547 :022?>   }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :023 > 
1.9.3-p547 :024 >   post_string = []
 => [] 
1.9.3-p547 :025 > post_vars.each_pair {|k, v| post_string << "#{k}=#{v}" }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :026 > post_string *= '&'
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :027 > 
1.9.3-p547 :028 >   post_string == temp
 => true 
1.9.3-p547 :029 >$ irb
1.9.3-p547 :001 > temp = "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :002 > 
1.9.3-p547 :003 >   
1.9.3-p547 :004 >   post_vars = {
1.9.3-p547 :005 >     'nameSchema'=>'givenName',
1.9.3-p547 :006 >     'emailSchema'=>'mail',
1.9.3-p547 :007 >     'phoneSchema'=>'telephoneNumber',
1.9.3-p547 :008 >     'postalSchema'=>'postalAddress',
1.9.3-p547 :009 >     'mailstopSchema'=>'l',
1.9.3-p547 :010 >     'citySchema'=>'physicalDeliveryOfficeName',
1.9.3-p547 :011 >     'stateSchema'=>'st',
1.9.3-p547 :012 >     'zipCodeSchema'=>'postalcode',
1.9.3-p547 :013 >     'countrySchema'=>'co',
1.9.3-p547 :014 >     'faxSchema'=>'facsimileTelephoneNumber',
1.9.3-p547 :015 >     'homeSchema'=>'homeDirectory',
1.9.3-p547 :016 >     'memberSchema'=>'memberOf',
1.9.3-p547 :017 >     'uidSchema'=>'uid',
1.9.3-p547 :018 >     'ldapSearchName'=>'test',
1.9.3-p547 :019 >     'ldapServerIndex'=>'default',
1.9.3-p547 :020 >     '_fun_function'=>'HTTP_LDAP_Search_fn',
1.9.3-p547 :021 >     'NextPage'=>'%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig'
1.9.3-p547 :022?>   }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :023 > 
1.9.3-p547 :024 >   post_string = []
 => [] 
1.9.3-p547 :025 > post_vars.each_pair {|k, v| post_string << "#{k}=#{v}" }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :026 > post_string *= '&'
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :027 > 
1.9.3-p547 :028 >   post_string == temp
 => true 
1.9.3-p547 :029 >$ irb
1.9.3-p547 :001 > temp = "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :002 > 
1.9.3-p547 :003 >   
1.9.3-p547 :004 >   post_vars = {
1.9.3-p547 :005 >     'nameSchema'=>'givenName',
1.9.3-p547 :006 >     'emailSchema'=>'mail',
1.9.3-p547 :007 >     'phoneSchema'=>'telephoneNumber',
1.9.3-p547 :008 >     'postalSchema'=>'postalAddress',
1.9.3-p547 :009 >     'mailstopSchema'=>'l',
1.9.3-p547 :010 >     'citySchema'=>'physicalDeliveryOfficeName',
1.9.3-p547 :011 >     'stateSchema'=>'st',
1.9.3-p547 :012 >     'zipCodeSchema'=>'postalcode',
1.9.3-p547 :013 >     'countrySchema'=>'co',
1.9.3-p547 :014 >     'faxSchema'=>'facsimileTelephoneNumber',
1.9.3-p547 :015 >     'homeSchema'=>'homeDirectory',
1.9.3-p547 :016 >     'memberSchema'=>'memberOf',
1.9.3-p547 :017 >     'uidSchema'=>'uid',
1.9.3-p547 :018 >     'ldapSearchName'=>'test',
1.9.3-p547 :019 >     'ldapServerIndex'=>'default',
1.9.3-p547 :020 >     '_fun_function'=>'HTTP_LDAP_Search_fn',
1.9.3-p547 :021 >     'NextPage'=>'%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig'
1.9.3-p547 :022?>   }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :023 > 
1.9.3-p547 :024 >   post_string = []
 => [] 
1.9.3-p547 :025 > post_vars.each_pair {|k, v| post_string << "#{k}=#{v}" }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :026 > post_string *= '&'
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :027 > 
1.9.3-p547 :028 >   post_string == temp
 => true 
1.9.3-p547 :029 >$ irb
1.9.3-p547 :001 > temp = "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :002 > 
1.9.3-p547 :003 >   
1.9.3-p547 :004 >   post_vars = {
1.9.3-p547 :005 >     'nameSchema'=>'givenName',
1.9.3-p547 :006 >     'emailSchema'=>'mail',
1.9.3-p547 :007 >     'phoneSchema'=>'telephoneNumber',
1.9.3-p547 :008 >     'postalSchema'=>'postalAddress',
1.9.3-p547 :009 >     'mailstopSchema'=>'l',
1.9.3-p547 :010 >     'citySchema'=>'physicalDeliveryOfficeName',
1.9.3-p547 :011 >     'stateSchema'=>'st',
1.9.3-p547 :012 >     'zipCodeSchema'=>'postalcode',
1.9.3-p547 :013 >     'countrySchema'=>'co',
1.9.3-p547 :014 >     'faxSchema'=>'facsimileTelephoneNumber',
1.9.3-p547 :015 >     'homeSchema'=>'homeDirectory',
1.9.3-p547 :016 >     'memberSchema'=>'memberOf',
1.9.3-p547 :017 >     'uidSchema'=>'uid',
1.9.3-p547 :018 >     'ldapSearchName'=>'test',
1.9.3-p547 :019 >     'ldapServerIndex'=>'default',
1.9.3-p547 :020 >     '_fun_function'=>'HTTP_LDAP_Search_fn',
1.9.3-p547 :021 >     'NextPage'=>'%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig'
1.9.3-p547 :022?>   }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :023 > 
1.9.3-p547 :024 >   post_string = []
 => [] 
1.9.3-p547 :025 > post_vars.each_pair {|k, v| post_string << "#{k}=#{v}" }
 => {"nameSchema"=>"givenName", "emailSchema"=>"mail", "phoneSchema"=>"telephoneNumber", "postalSchema"=>"postalAddress", "mailstopSchema"=>"l", "citySchema"=>"physicalDeliveryOfficeName", "stateSchema"=>"st", "zipCodeSchema"=>"postalcode", "countrySchema"=>"co", "faxSchema"=>"facsimileTelephoneNumber", "homeSchema"=>"homeDirectory", "memberSchema"=>"memberOf", "uidSchema"=>"uid", "ldapSearchName"=>"test", "ldapServerIndex"=>"default", "_fun_function"=>"HTTP_LDAP_Search_fn", "NextPage"=>"%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig"} 
1.9.3-p547 :026 > post_string *= '&'
 => "nameSchema=givenName&emailSchema=mail&phoneSchema=telephoneNumber&postalSchema=postalAddress&mailstopSchema=l&citySchema=physicalDeliveryOfficeName&stateSchema=st&zipCodeSchema=postalcode&countrySchema=co&faxSchema=facsimileTelephoneNumber&homeSchema=homeDirectory&memberSchema=memberOf&uidSchema=uid&ldapSearchName=test&ldapServerIndex=default&_fun_function=HTTP_LDAP_Search_fn&NextPage=%2Fldap%2Fmappings.php%3Fldapindex%3Ddefault%26from%3DldapConfig" 
1.9.3-p547 :027 > 
1.9.3-p547 :028 >   post_string == temp
 => true 
1.9.3-p547 :029 >
```

The ```true``` indicates your string is not mangled in the process, therefore safe to use.