【C#】破解HG221GS光猫超级用户密码

自家使用的光猫型号为华为HG221GS,由于想要打开光猫的端口必须要超级管理员(telecomadmin)而非用户管理员(useradmin),

又因为每台设备的密码都不相同,所以有了这个小程序

本程序源自一段python代码的移植,

list=[120,105,112,105,103,115,113,101,104,113,109,114,53,48,54,55,54,51,51,57]
result=[]
for i in list:
    if i > 57:
        i-=4
    result.append(chr(i))
print ''.join(result)

(原作者:jzking121)

移植为.net程序后更易用了

其实是窝太懒

《【C#】破解HG221GS光猫超级用户密码》

窗体:

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="Carck Modem Password" Height="191" Width="323"
        ResizeMode="NoResize"
       
        >
    <Grid>
        <TextBox x:Name="desc" Height="120" TextWrapping="Wrap" Text="请在浏览器中打开 http://192.168.1.1/cgi-bin/baseinfoSet.cgi&#xA;并将 baseinfoSet_TELECOMPASSWORD 字段内容填入下框中&#xA;(仅适用于HG221GS电信光猫)" VerticalAlignment="Top" TextChanged="TextBox_TextChanged" Margin="10,10,0,0" HorizontalAlignment="Left" Width="297" IsReadOnly="True" Grid.Column="1"/>
        <TextBox x:Name="userinput" HorizontalAlignment="Left" TextWrapping="NoWrap" Width="230" Margin="10,136,0,0" Height="21" VerticalAlignment="Top"/>
        <Button Content="GO" HorizontalAlignment="Left" Height="21" Margin="245,136,0,0" VerticalAlignment="Top" Width="62" RenderTransformOrigin="0.476,0.5" Click="Button_Click"/>
    </Grid>
</Window>

代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            String InputVal = this.userinput.Text;
            String OutputVal = "";

            try
            {
                String[] WorkVal = InputVal.Split(new string[] { "&" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (String item0 in WorkVal)
                {
                    int item1 = Convert.ToInt16(item0);
                    if (item1 > 57)
                    {
                        item1 -= 4;
                    }
                    OutputVal += Convert.ToChar(item1);
                }
            }
            catch
            {
                MessageBox.Show("输入的格式不正确!", "Error");
                return;
            }

            Clipboard.SetDataObject(OutputVal);
            MessageBox.Show($"超级用户(telecomadmin)的密码为 {OutputVal} ,已复制到剪贴板!", "Success");
        }
    }
}

 

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注