* Standardized examples logger init method
* Fixing missing import
* Standardized examples init_ldap_session function #1
* Calling new shared function _ldap3_kerberos_login from example addcomputer
* Removed considering -debug in each example. Now it's handled in utils.
* Standardized EMPTY_LM_HASH in impacket.examples.utils
* Unify parse_identity function (phase 1)
* Standardized parse_identity
* Renamed "_ldap3_kerberos_login" to "ldap3_kerberos_login" (as it is called from outside)
* Standardize "logger" init in regsecrets.py
* Standardized LDAP login into a single function in utils.py:ldap_login
* Setting "log_file" property to "None" for smbserver configuration file ~ will print to console
* Setting "log_file" property to "None" for smbrelayx.py
* Deleted 'BTOBTO' hardcoded service name
* Deleted output file if still in share
* Fixed deleting output file
* Moved random string generation
* Deleted extra lines
Using the RFC1060 localhost IP doesn't resolve successfully on
all machines:
C:\>echo foo > \\127.0.0.1\C$\bar
echo foo > \\127.0.0.1\C$\bar
The specified user does not exist.
C:\>echo foo > \\localhost\C$\bam
echo foo > \\localhost\C$\bam
You were not connected because a duplicate name exists on the network. Go to System in Control Panel to change the computer name and try again.
C:\>echo fo > \\localhost.localdomain\C$\bam
echo fo > \\localhost.localdomain\C$\bam
The network path was not found.
However, UNC paths work well and are documented to use the computer's
name for addressing. Hence, switch to %COMPUTERNAME% for more reliable
execution.
Otherwise we may have errors such as:
impacket.dcerpc.v5.scmr.DCERPCSessionError: SCMR SessionError: code: 0x41d - ERROR_SERVICE_REQUEST_TIMEOUT - The service did not respond to the start or control request in a timely fashion.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/impacket/smbconnection.py", line 769, in getFile
return self._SMBConnection.retr_file(shareName, pathName, callback)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/impacket/smb.py", line 4009, in retr_file
fid = self.nt_create_andx(tid, filename, shareAccessMode = shareAccessMode, accessMask = 0x20089)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jkoenig/MS17-010/examples/smbexec.py", line 206, in nt_create_andx
self._last_fid = smb.SMB.nt_create_andx(self, tid, filename, smb_packet, cmd, shareAccessMode, disposition, accessMask)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/impacket/smb.py", line 3896, in nt_create_andx
if smb.isValidAnswer(SMB.SMB_COM_NT_CREATE_ANDX):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/impacket/smb.py", line 778, in isValidAnswer
raise SessionError("SMB Library Error", self['ErrorClass'] + (self['_reserved'] << 8), self['ErrorCode'], self['Flags2'] & SMB.FLAGS2_NT_STATUS, self)
impacket.smb.SessionError: SMB SessionError: STATUS_OBJECT_NAME_NOT_FOUND(The object name is not found.)
CRITICAL:root:SMB SessionError: STATUS_OBJECT_NAME_NOT_FOUND(The object name is not found.)
This was a pending change to:
- Use the same tagline, copyright and license notice across files.
- Remove authors' contacts that are no longer valid (due to affiliation changes).
- Update repository location.
- Update license file with missing licenses (althought those were already in source files).
This doesn't include any change on the source code, nor any change on current copyright or licenses. Just formatting and phrasing to make our and distro's maintainers life easier.
In reviewing #1051 (and related #347) we found out that there's some ugly duplicated code that's better suited for an utils function.
The expected target format is:
`<DOMAIN></USERNAME><:PASSWORD>@HOSTNAME`
This PR:
- Moved target parsing routine to an utils module.
- Added unit tests for the new function.
- Using the new function across example scripts that accept a target.
Replaced all instances of `#!/usr/bin/python` with `#!/usr/bin/env python` so impacket's examples and scripts can be run inside a virtualenv without having to call python.
Now there should be a single logger called 'impacket' the library uses.
By default is has a NullHandler so nothing is printed, but messages are
forwarded to the upstream logger.
If you are a script using the library and want to set the root logger
with a custom formatter, you can import impacket.examples.logger.
After some testing I'll merge it into master