├── src ├── ip.c ├── debug.h ├── main.c ├── h3c_AES_MD5 │ ├── h3c_AES_MD5.c │ ├── h3c_AES_MD5.h │ ├── aes.h │ └── aes.c ├── auth.h ├── pcaphelper.h ├── 8021xclient.h ├── md5 │ ├── md5.h │ └── md5.c └── auth.c ├── Nxsharp ├── iNode ClientGR.ico ├── iNode ClientR.ico ├── Resources │ └── services.ico ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── app.config ├── Form3.cs ├── Form2.cs ├── Form3.resx ├── Program.cs ├── Form1.cs ├── Form2.resx ├── nxsharp.csproj ├── Form2.Designer.cs ├── Form3.Designer.cs └── Form1.Designer.cs ├── documents ├── h3c_AES_MD5.png ├── Documents.html └── h3c_AES_MD5.md ├── WpdPack └── readme.txt ├── README.md ├── xclient.vcxproj.filters ├── nxsharp.sln ├── .gitignore ├── xclient.vcxproj └── License └── gpl-3.0.txt /src/ip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/src/ip.c -------------------------------------------------------------------------------- /src/debug.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/src/debug.h -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/src/main.c -------------------------------------------------------------------------------- /Nxsharp/iNode ClientGR.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/Nxsharp/iNode ClientGR.ico -------------------------------------------------------------------------------- /Nxsharp/iNode ClientR.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/Nxsharp/iNode ClientR.ico -------------------------------------------------------------------------------- /documents/h3c_AES_MD5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/documents/h3c_AES_MD5.png -------------------------------------------------------------------------------- /Nxsharp/Resources/services.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/Nxsharp/Resources/services.ico -------------------------------------------------------------------------------- /src/h3c_AES_MD5/h3c_AES_MD5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitdust/nxsharp/HEAD/src/h3c_AES_MD5/h3c_AES_MD5.c -------------------------------------------------------------------------------- /src/auth.h: -------------------------------------------------------------------------------- 1 | __declspec(dllexport) int Authentication(const char *UserName, const char *Password, const char *DeviceName); -------------------------------------------------------------------------------- /WpdPack/readme.txt: -------------------------------------------------------------------------------- 1 | 此目录用于存放winpcap提供的第三方库。 2 | 例如: 3 | 4 | WpdPack\docs\ 5 | WpdPack\Examples-pcap\ 6 | WpdPack\Examples-remote\ 7 | WpdPack\Include\ 8 | WpdPack\Lib\ 9 | WpdPack\readme.txt 10 | 11 | 其中最重要的是 Include 文件夹与 Lib 文件夹。 12 | -------------------------------------------------------------------------------- /src/pcaphelper.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _PCAP_HELPER_H_ 3 | #define _PCAP_HELPER_H_ 1 4 | 5 | #pragma once 6 | 7 | #pragma comment(lib, "wpcap.lib") 8 | #pragma comment(lib, "Packet.lib") 9 | 10 | #include 11 | #include 12 | 13 | #endif -------------------------------------------------------------------------------- /src/8021xclient.h: -------------------------------------------------------------------------------- 1 | #ifndef NJIT8021XCLIENT_H 2 | #define NJIT8021XCLIENT_H 3 | 4 | extern const struct GlobalConfig { 5 | const char *package_name; 6 | const char *package_version; 7 | const char *locale_dir; 8 | } g_config; 9 | 10 | #endif//nJIT8021XCLIENT_H 11 | -------------------------------------------------------------------------------- /src/h3c_AES_MD5/h3c_AES_MD5.h: -------------------------------------------------------------------------------- 1 | #ifndef h3c_AES_MD5_ 2 | #define h3c_AES_MD5_ 3 | #include 4 | int h3c_AES_MD5_decryption(unsigned char *decrypt_data, unsigned char *encrypt_data); 5 | int test(); 6 | char* get_sig(uint32_t index, int offset, int length, unsigned char* dst); 7 | #endif -------------------------------------------------------------------------------- /Nxsharp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Nxsharp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34209 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace gui.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Nxsharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息通过以下 6 | // 特性集控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("NXSharp")] 9 | [assembly: AssemblyDescription("njit8021xclient-sharp")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 使此程序集中的类型 18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | // 则将该类型上的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("7d3858ff-7ff4-49fe-97e3-1a93df54641d")] 24 | 25 | // 程序集的版本信息由下面四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("3.5.0.0")] 36 | [assembly: AssemblyFileVersion("3.5.0.0")] 37 | -------------------------------------------------------------------------------- /src/h3c_AES_MD5/aes.h: -------------------------------------------------------------------------------- 1 | #ifndef _AES_H_ 2 | #define _AES_H_ 3 | 4 | #include 5 | 6 | 7 | // #define the macros below to 1/0 to enable/disable the mode of operation. 8 | // 9 | // CBC enables AES128 encryption in CBC-mode of operation and handles 0-padding. 10 | // ECB enables the basic ECB 16-byte block algorithm. Both can be enabled simultaneously. 11 | 12 | // The #ifndef-guard allows it to be configured before #include'ing or at compile time. 13 | #ifndef CBC 14 | #define CBC 1 15 | #endif 16 | 17 | #ifndef ECB 18 | #define ECB 1 19 | #endif 20 | 21 | 22 | 23 | #if defined(ECB) && ECB 24 | 25 | void AES128_ECB_encrypt(uint8_t* input, const uint8_t* key, uint8_t *output); 26 | void AES128_ECB_decrypt(uint8_t* input, const uint8_t* key, uint8_t *output); 27 | 28 | #endif // #if defined(ECB) && ECB 29 | 30 | 31 | #if defined(CBC) && CBC 32 | 33 | void AES128_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv); 34 | void AES128_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv); 35 | 36 | #endif // #if defined(CBC) && CBC 37 | 38 | 39 | 40 | #endif //_AES_H_ 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NXSharp 2 | 即 njit8021xclient-sharp 3 | 认证算法与我的Linux分支[njit8021xclient](https://github.com/bitdust/njit8021xclient)同步 4 | 5 | fork from 6 | --- 7 | njit8021xclient: https://github.com/liuqun/njit8021xclient 8 | 9 | 本项目是[tengattack的windows分支](https://github.com/tengattack/8021xclient-for-windows)的修改,将其输出修改为DLL文件。添加了Nxsharp(njit8021xclient-sharp的缩写)程序作为GUI前端。同时完成了对inode7.0中的[AES128验证算法](./documents/h3c_AES_MD5.md)的支持。 10 | 11 | features 12 | --- 13 | * windows 图形界面 14 | * 断线自动重连 15 | * h3c-AES-MD5 算法支持 16 | * 可以配置认证版本号、认证密钥(获取方法见 [H3C_toolkit](https://github.com/bitdust/H3C_toolkit) 项目) 17 | 18 | screenshot 19 | --- 20 | ![screenshot](https://cloud.githubusercontent.com/assets/6072743/11125371/8796e67c-89a4-11e5-8ffb-7861f1e2c246.png) 21 | 22 | release 23 | --- 24 | 最新版本NXSharp下载地址:https://github.com/bitdust/nxsharp/releases 25 | 26 | depends on 27 | --- 28 | WinPcap: http://www.winpcap.org/ 29 | dotNet Framework 3.5~4.5: http://www.microsoft.com/ 30 | 31 | build 32 | --- 33 | 编译环境 Visual Studio 2013 34 | 35 | 依赖 winpcap,请从官方网站下载 36 | 37 | [Winpcap二进制安装包](http://www.winpcap.org/install/default.htm) 38 | 以及 39 | [Winpcap开发包](http://www.winpcap.org/devel.htm),并将其解压放置于Wpdpack文件夹中。 40 | 41 | more info 42 | --- 43 | [关于inode7.0中基于AES128的验证算法](./documents/h3c_AES_MD5.md) 44 | 45 | -------------------------------------------------------------------------------- /Nxsharp/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Nxsharp/Form3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace gui 11 | { 12 | public partial class Form3 : Form 13 | { 14 | public Form3() 15 | { 16 | InitializeComponent(); 17 | textBox1.Text = Cfg.versionHEX; 18 | textBox2.Text = Cfg.VersionParser(Cfg.versionHEX); 19 | textBox3.Text = Cfg.H3C_key; 20 | textBox4.Text = Cfg.H3C_key; 21 | } 22 | 23 | private void button1_Click(object sender, EventArgs e) 24 | { 25 | if (textBox1.Text.Length % 2 != 0 || textBox1.Text.Length > 32 || textBox1.Text.Length < 2) 26 | { 27 | MessageBox.Show("输入版本号信息不正确!"); 28 | textBox1.Text = ""; 29 | } 30 | else if (textBox3.Text.Length > 20) 31 | { 32 | MessageBox.Show("输入密钥过长!"); 33 | textBox1.Text = ""; 34 | } 35 | else 36 | { 37 | Cfg.versionHEX = textBox1.Text; 38 | Cfg.H3C_key = textBox3.Text; 39 | Cfg.Commit(); 40 | textBox2.Text = Cfg.VersionParser(textBox1.Text); 41 | textBox4.Text = Cfg.H3C_key; 42 | } 43 | } 44 | 45 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 46 | { 47 | System.Diagnostics.Process.Start("iexplore.exe", "https://github.com/bitdust/H3C_toolkit"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xclient.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 源文件 32 | 33 | 34 | 源文件 35 | 36 | 37 | 38 | 39 | 头文件 40 | 41 | 42 | 头文件 43 | 44 | 45 | 头文件 46 | 47 | 48 | 头文件 49 | 50 | 51 | -------------------------------------------------------------------------------- /documents/Documents.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | NJIT 802.1X Client -- Documents 4 | 5 | 6 |
  7 | ===============================================================================
  8 | 南京工程学院 - 校园网802.1X客户端 - 项目文档
  9 | -------------------------------------------------------------------------------
 10 | 参考AGanNo2的相关介绍,在此将版本号加密/解密步骤整理如下。
 11 | 
 12 | [H3C版本号加密流程]
 13 | 
 14 | 选取任意32位随机数,并生成字符串形式的密钥
 15 | 	uint32_t   randam;
 16 | 	char       key[8+1];
 17 | 	sprintf(key, "%08x", randam);
 18 | 
 19 | 
 20 | 加密步骤:
 21 | char version[16]="EN V2.40-0335";
 22 |      |
 23 |      |   异或
 24 |      |《———————— key[]   (例如取randam=0x12345678,则字符串key[]为"12345678")
 25 |      |
 26 | version[16]: "LK%W3+19$5624  "
 27 |      |
 28 |      |   将整数randam附加到version[16]之后,组成20字节
 29 |      |《—————————————————————————————————————————————
 30 |      |
 31 | version[20]: "LK%W3+19$5624   4Vx"
 32 |      |
 33 |      |   异或
 34 |      |《——————— "HuaWei3COM1X"
 35 |      |
 36 | version[20]: "; <s23IJ%?C       "
 37 |      |
 38 |      |   按照Base64格式编码,输出可读的ASCII字符串
 39 |      |《——————————————————————————————————————————
 40 |      |
 41 | 最后生成的28字节版本号为:
 42 | Rw0tZQEjdzIzSUolP0MNOyA8EHM=
 43 | 
 44 | 
 45 | 
 46 | 
 47 | [“异或”运算的细节]
 48 | 1、每个密钥被按正序、逆序使用两遍
 49 | 2、密钥会被扩展为与待加密数据长度相同
 50 | 
 51 | 使用密钥key[]="12345678"加密"EN V2.40-0335":
 52 | 
 53 | 	"EN V2.40-0335   "
 54 | 	"1234567812345678"
 55 | XOR	"8765432187654321"
 56 | ————————————————————————————————
 57 | 	"LK%W3+19$5624   "
 58 | 
 59 | 
 60 | 
 61 | 使用密钥"HuaWei3COM1X"加密"LK%W3+19$5624   4Vx":
 62 | 
 63 | 	"LK%W3+19$5624   4Vx"
 64 | 	"HuaWei3COM1XHuaWei3C"
 65 | XOR	"C3ieWauHX1MOC3ieWauH"
 66 | ————————————————————————————————
 67 | 	"; <s23IJ%?C       "
 68 | 
 69 | 
 70 | 
 71 | 
 72 | [H3C认证服务器解读版本号流程]
 73 | 
 74 | 28字节版本号秘文
 75 |    |
 76 |    |  Base64解码
 77 |    |《—————————————
 78 |    |
 79 | verison[20]
 80 |    |
 81 |    |  异或
 82 |    |《———————— "HuaWei3COM1X"
 83 |    |
 84 | version[20]
 85 |    |  \ 
 86 |    |   \
 87 |  前16字节  取出末尾4字节,即randam
 88 |    |       |
 89 |    |       |
 90 |    |       |
 91 |    |  异或   |
 92 |    |《—————— key[]
 93 |    |
 94 |    |
 95 | 还原成版本号字符串"EN V2.40-0335"
 96 | 
 97 | ===============================================================================
 98 | 		
99 | 100 | 101 | -------------------------------------------------------------------------------- /src/md5/md5.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_MD5_H_ 6 | #define BASE_MD5_H_ 7 | #pragma once 8 | 9 | #define BASE_EXPORT 10 | 11 | // MD5 stands for Message Digest algorithm 5. 12 | // MD5 is a robust hash function, designed for cyptography, but often used 13 | // for file checksums. The code is complex and slow, but has few 14 | // collisions. 15 | // See Also: 16 | // http://en.wikipedia.org/wiki/MD5 17 | 18 | // These functions perform MD5 operations. The simplest call is MD5Sum() to 19 | // generate the MD5 sum of the given data. 20 | // 21 | // You can also compute the MD5 sum of data incrementally by making multiple 22 | // calls to MD5Update(): 23 | // MD5Context ctx; // intermediate MD5 data: do not use 24 | // MD5Init(&ctx); 25 | // MD5Update(&ctx, data1, length1); 26 | // MD5Update(&ctx, data2, length2); 27 | // ... 28 | // 29 | // MD5Digest digest; // the result of the computation 30 | // MD5Final(&digest, &ctx); 31 | // 32 | // You can call MD5DigestToBase16() to generate a string of the digest. 33 | 34 | // The output of an MD5 operation. 35 | struct MD5Digest { 36 | unsigned char a[16]; 37 | }; 38 | 39 | // Used for storing intermediate data during an MD5 computation. Callers 40 | // should not access the data. 41 | typedef char MD5Context[88]; 42 | 43 | // Computes the MD5 sum of the given data buffer with the given length. 44 | // The given 'digest' structure will be filled with the result data. 45 | BASE_EXPORT void MD5Sum(const void* data, size_t length, struct MD5Digest* digest); 46 | 47 | // Initializes the given MD5 context structure for subsequent calls to 48 | // MD5Update(). 49 | BASE_EXPORT void MD5Init(MD5Context* context); 50 | 51 | // For the given buffer of |data| as a StringPiece, updates the given MD5 52 | // context with the sum of the data. You can call this any number of times 53 | // during the computation, except that MD5Init() must have been called first. 54 | BASE_EXPORT void MD5Update(MD5Context* context, const unsigned char *data, size_t length); //const StringPiece& data); 55 | 56 | // Finalizes the MD5 operation and fills the buffer with the digest. 57 | BASE_EXPORT void MD5Final(struct MD5Digest* digest, MD5Context* context); 58 | 59 | BASE_EXPORT void MD5Calc(unsigned char *data, unsigned int len, unsigned char *output); 60 | 61 | 62 | #endif // BASE_MD5_H_ 63 | -------------------------------------------------------------------------------- /Nxsharp/Form2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.IO; 10 | using System.Resources; 11 | 12 | namespace gui 13 | { 14 | public partial class Form2 : Form 15 | { 16 | public Form2() 17 | { 18 | InitializeComponent(); 19 | if (Cfg.mode == 1) 20 | { 21 | modeButton2.Checked = true; 22 | } 23 | else if(Cfg.mode == 2) 24 | { 25 | modeButton3.Checked = true; 26 | } 27 | else if (Cfg.mode == 0) 28 | { 29 | modeButton1.Checked = true; 30 | } 31 | } 32 | private void button1_Click(object sender, EventArgs e) 33 | { 34 | if (NetworkInterfaceAvaliable.adapters_dict.ContainsKey(Cfg.device)) 35 | { 36 | NetworkInterfaceAvaliable.RefreshDHCP(NetworkInterfaceAvaliable.adapters_dict[Cfg.device]); 37 | } 38 | else 39 | { 40 | MessageBox.Show("你没有选择网卡!"); 41 | this.Close(); 42 | } 43 | } 44 | 45 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 46 | { 47 | System.Diagnostics.Process.Start("iexplore.exe", "https://github.com/bitdust/nxsharp/releases"); 48 | } 49 | 50 | private void button3_Click(object sender, EventArgs e) 51 | { 52 | Form3 f3 = new Form3(); 53 | f3.ShowDialog(); 54 | } 55 | 56 | private void modeButton1_CheckedChanged(object sender, EventArgs e) 57 | { 58 | if(modeButton1.Checked) 59 | { 60 | Cfg.mode = 0; 61 | Cfg.Commit(); 62 | } 63 | } 64 | 65 | private void modeButton2_CheckedChanged(object sender, EventArgs e) 66 | { 67 | if (modeButton2.Checked) 68 | { 69 | Cfg.mode = 1; 70 | Cfg.Commit(); 71 | } 72 | 73 | } 74 | 75 | private void modeButton3_CheckedChanged(object sender, EventArgs e) 76 | { 77 | if (modeButton3.Checked) 78 | { 79 | Cfg.mode = 2; 80 | Cfg.Commit(); 81 | } 82 | } 83 | 84 | private void Form2_Load(object sender, EventArgs e) 85 | { 86 | 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Nxsharp/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.34209 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace gui.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("gui.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 使用此强类型资源类,为所有资源查找 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /documents/h3c_AES_MD5.md: -------------------------------------------------------------------------------- 1 | # inode 7.0 AES-MD5验证算法 2 | inode7.0客户端上传的心跳包中有可能携带以 0x16 0x20 为开头的 32 位(不包括 0x16 0x20 )加密序列,作为客户端合法性验证。 3 | 这一序列在接收到 EAP code 为 0x0A 的数据包之后产生。可以合理推断其生成方式与 0x0A 数据包相关。 4 | 5 | 举例说明其生成流程: 6 | --- 7 | ### 第一步: 8 | 从 0x0A 数据包中获取以 0x2b 0x35 为开头的 32 位序列(不包括 0x2b 0x35 ): 9 | { 0xcf, 0xfe, 0x64, 0x73, 0xd5, 0x73, 0x3b, 0x1f, 0x9e, 0x9a, 0xee, 0x1a, 0x6b, 0x76, 0x47, 0xc8, 0x9e, 0x27, 0xc8, 0x92, 0x25, 0x78, 0xc4, 0xc8, 0x27, 0x03, 0x34, 0x50, 0xb6, 0x10, 0xb8, 0x35 } 10 | 11 | ### 第二步: 12 | 将该序列进行 32 位 AES128 解密。 13 | 14 | 密钥为: 15 | {0xEC, 0xD4, 0x4F, 0x7B, 0xC6, 0xDD, 0x7D, 0xDE, 0x2B, 0x7B, 0x51, 0xAB, 0x4A, 0x6F, 0x5A, 0x22} 16 | 初始向量(IV)为: 17 | { 'a', '@', '4', 'd', 'e', '%', '#', '1', 'a', 's', 'd', 'f', 's', 'd', '2', '4' } 18 | 19 | **解密结果为:** 20 | 57 cc 1a a3 87 0d 38 36 66 35 65 64 34 38 39 36 44 58 5f a4 c5 7b b2 c8 34 11 67 33 f0 a3 ab 0a 21 | 22 | ### 第三步: 23 | 取解密结果的前 16 位: 57 cc 1a a3 87 0d 38 36 66 35 65 64 34 38 39 36 24 | 其中第1~4位:57 cc 1a a3 为索引序列,第五位 87 为偏移量,第六位 0d 为长度。 25 | 从查找表中查找 57 cc 1a a3 指示的序列中以 87 为初始偏移量,0d 长度的序列。 26 | 27 | **说明:**这一操作需要的查找表来自 inode 程序本身,本质是对程序自身完整性的验证。这也意味着不同单位所需要构造的查找表可能完全不同,需要结合实际分析。查找表字典的提取方法比较复杂,请参考教程:https://github.com/bitdust/H3C_toolkit/issues/4 28 | 29 | **查找结果为:** 30 | fa 2a 8d 0c 3e 8d 44 08 01 75 32 83 c5 31 | 32 | ### 第四步: 33 | 对第三步的结果进行 MD5 计算 34 | 35 | **MD5 结果为:** 36 | a8 7b 85 f0 8b 44 da 1d ad 0e 6f bb 04 30 ba 8f 37 | 38 | ### 第五步: 39 | 取第二步解密结果的后 16 位为密文: 40 | 44 58 5f a4 c5 7b b2 c8 34 11 67 33 f0 a3 ab 0a 41 | 取第四步的 MD5 计算结果为密钥: 42 | a8 7b 85 f0 8b 44 da 1d ad 0e 6f bb 04 30 ba 8f 43 | 重新设置初始向量 IV 为(注意:许多 AES 加密库的 IV 会在使用之后自动改变,因此需要重置后使用): 44 | { 'a', '@', '4', 'd', 'e', '%', '#', '1', 'a', 's', 'd', 'f', 's', 'd', '2', '4' } 45 | 进行 16 位 AES 解密 46 | 47 | **解密结果为:** 48 | 38 30 39 35 32 65 62 35 38 66 97 d0 23 7c 38 09 49 | 50 | ### 第六步: 51 | 取第二步的解密结果前 16 位与第五步的解密结果拼接为一个新的序列: 52 | 53 | **拼接结果为:** 54 | 57 cc 1a a3 87 0d 38 36 66 35 65 64 34 38 39 36 38 30 39 35 32 65 62 35 38 66 97 d0 23 7c 38 09 55 | 56 | ### 第七步: 57 | 取第五的解密结果:38 30 39 35 32 65 62 35 38 66 97 d0 23 7c 38 09 58 | 其中第 10~14 位:97 d0 23 7c 为索引序列,第 15 位 0x38 为偏移量,第 16 位 0x09 为长度。 59 | 从查找表中查找 97 d0 23 7c 指示的序列中以 0x38 为初始偏移量,0x09 长度的序列。 60 | 61 | **查找结果为:** 62 | 00 00 00 8b b4 24 10 12 00 63 | 64 | ### 第八步: 65 | 取第三步的查找结果与第七步的查找结果拼接为新的序列, 66 | 67 | **拼接结果为:** 68 | fa 2a 8d 0c 3e 8d 44 08 01 75 32 83 c5 00 00 00 8b b4 24 10 12 00 69 | 70 | ### 第九步: 71 | 将第八步的拼接结果“覆盖”于第六步的拼接结果之上。 72 | 73 | **说明:**“覆盖”,意味着将新序列的值按位写入到老的序列上,如果新序列长度小于老序列,则老序列未被重写的位置仍保留原有的值;如果新序列长度大于老序列,新序列首先会被截取以免溢出。 74 | 举例: 75 | 老序列:1 2 3 4 5 76 | 新序列:7 8 9 77 | 覆盖结果:7 8 9 4 5 78 | 79 | **覆盖结果为:** 80 | fa 2a 8d 0c 3e 8d 44 08 01 75 32 83 c5 00 00 00 8b b4 24 10 12 00 62 35 38 66 97 d0 23 7c 38 09 81 | 82 | ### 第十步: 83 | 取第九步的结果进行一次 MD5 运算,结果为: 84 | 87 19 36 28 33 10 8a 6e 16 b0 8e 33 94 36 01 54 85 | 取上一 MD5 结果再进行一次 MD5 运算,结果为: 86 | 25 11 37 2d 8d 1f b1 ab 31 aa 17 05 91 18 a6 ba 87 | 将两次MD5运算结果进行拼接,则可得最终心跳包中的序列。 88 | 89 | **最终结果:** 90 | 87 19 36 28 33 10 8a 6e 16 b0 8e 33 94 36 01 54 25 11 37 2d 8d 1f b1 ab 31 aa 17 05 91 18 a6 ba 91 | 92 | 综上,该算法综合利用了 AES128 算法以及 MD5 算法,因此暂命名为:h3c-AES-MD5 算法。 93 | 94 | 流程图: 95 | --- 96 | ![h3c_AES_MD5](./h3c_AES_MD5.png) 97 | 98 | 参考代码: 99 | --- 100 | [h3c_AES_MD5.c](../src/h3c_AES_MD5.c) 101 | -------------------------------------------------------------------------------- /nxsharp.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xclient", "xclient.vcxproj", "{FBFE083E-43A7-485A-9B87-334D1B2EB76B}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nxsharp", "Nxsharp\nxsharp.csproj", "{D561E655-72C1-43B9-8BF8-1775BE56CF6F}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B} = {FBFE083E-43A7-485A-9B87-334D1B2EB76B} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Debug|Mixed Platforms = Debug|Mixed Platforms 17 | Debug|Win32 = Debug|Win32 18 | Debug|x86 = Debug|x86 19 | Release|Any CPU = Release|Any CPU 20 | Release|Mixed Platforms = Release|Mixed Platforms 21 | Release|Win32 = Release|Win32 22 | Release|x86 = Release|x86 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Debug|Any CPU.ActiveCfg = Debug|Win32 26 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 27 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 28 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Debug|Win32.Build.0 = Debug|Win32 30 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Debug|x86.ActiveCfg = Debug|Win32 31 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Debug|x86.Build.0 = Debug|Win32 32 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Release|Any CPU.ActiveCfg = Release|Win32 33 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 34 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Release|Mixed Platforms.Build.0 = Release|Win32 35 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Release|Win32.ActiveCfg = Release|Win32 36 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Release|Win32.Build.0 = Release|Win32 37 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Release|x86.ActiveCfg = Release|Win32 38 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B}.Release|x86.Build.0 = Release|Win32 39 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 42 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|Mixed Platforms.Build.0 = Debug|x86 43 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|Win32.ActiveCfg = Debug|x86 44 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|Win32.Build.0 = Debug|x86 45 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|x86.ActiveCfg = Debug|x86 46 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Debug|x86.Build.0 = Debug|x86 47 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|Any CPU.ActiveCfg = Release|Any CPU 48 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|Any CPU.Build.0 = Release|Any CPU 49 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|Mixed Platforms.ActiveCfg = Release|x86 50 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|Mixed Platforms.Build.0 = Release|x86 51 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|Win32.ActiveCfg = Release|x86 52 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|Win32.Build.0 = Release|x86 53 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|x86.ActiveCfg = Release|x86 54 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F}.Release|x86.Build.0 = Release|x86 55 | EndGlobalSection 56 | GlobalSection(SolutionProperties) = preSolution 57 | HideSolutionNode = FALSE 58 | EndGlobalSection 59 | EndGlobal 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # ASP.NET 5 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding addin-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | # TODO: Comment the next line if you want to checkin your web deploy settings 137 | # but database connection strings (with potential passwords) will be unencrypted 138 | *.pubxml 139 | *.publishproj 140 | 141 | # NuGet Packages 142 | *.nupkg 143 | # The packages folder can be ignored because of Package Restore 144 | **/packages/* 145 | # except build/, which is used as an MSBuild target. 146 | !**/packages/build/ 147 | # Uncomment if necessary however generally it will be regenerated when needed 148 | #!**/packages/repositories.config 149 | 150 | # Windows Azure Build Output 151 | csx/ 152 | *.build.csdef 153 | 154 | # Windows Store app package directory 155 | AppPackages/ 156 | 157 | # Others 158 | *.[Cc]ache 159 | ClientBin/ 160 | [Ss]tyle[Cc]op.* 161 | ~$* 162 | *~ 163 | *.dbmdl 164 | *.dbproj.schemaview 165 | *.pfx 166 | *.publishsettings 167 | node_modules/ 168 | bower_components/ 169 | 170 | # RIA/Silverlight projects 171 | Generated_Code/ 172 | 173 | # Backup & report files from converting an old project file 174 | # to a newer Visual Studio version. Backup files are not needed, 175 | # because we have git ;-) 176 | _UpgradeReport_Files/ 177 | Backup*/ 178 | UpgradeLog*.XML 179 | UpgradeLog*.htm 180 | 181 | # SQL Server files 182 | *.mdf 183 | *.ldf 184 | 185 | # Business Intelligence projects 186 | *.rdl.data 187 | *.bim.layout 188 | *.bim_*.settings 189 | 190 | # Microsoft Fakes 191 | FakesAssemblies/ 192 | 193 | # Node.js Tools for Visual Studio 194 | .ntvs_analysis.dat 195 | 196 | # Visual Studio 6 build log 197 | *.plg 198 | 199 | # Visual Studio 6 workspace options file 200 | *.opt 201 | 202 | /tmp 203 | /xclient.sdf 204 | /xclient.v11.suo 205 | /Debug 206 | OpenSSL-Win32/ 207 | WpdPack/ 208 | *.dll 209 | *.exe 210 | Nxsharp/obj/ 211 | Release/NXSharp.exe 212 | *.ac 213 | *.dll 214 | *.orig 215 | *.cd 216 | *.dll 217 | *.exe 218 | Release/xclient.dll 219 | Nxsharp/Resources/NXSharp.exe.config 220 | -------------------------------------------------------------------------------- /xclient.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | {FBFE083E-43A7-485A-9B87-334D1B2EB76B} 29 | Win32Proj 30 | xclient 31 | 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | Static 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | true 59 | $(ProjectDir)\src;$(SolutionDir)\WpdPack\Include;$(IncludePath) 60 | $(SolutionDir)\WpdPack\Lib;$(LibraryPath) 61 | tmp\$(Configuration)\ 62 | 63 | 64 | false 65 | $(ProjectDir)\src;$(SolutionDir)\WpdPack\Include;$(IncludePath) 66 | $(SolutionDir)\WpdPack\Lib;$(LibraryPath) 67 | tmp\$(Configuration)\ 68 | 69 | 70 | 71 | NotUsing 72 | Level3 73 | Disabled 74 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) 75 | 76 | 77 | Console 78 | true 79 | %(AdditionalDependencies) 80 | 81 | 82 | 83 | 84 | Level3 85 | NotUsing 86 | MaxSpeed 87 | true 88 | true 89 | WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) 90 | 91 | 92 | Console 93 | false 94 | true 95 | true 96 | %(AdditionalDependencies) 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Nxsharp/Form3.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Nxsharp/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Nxsharp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | using System.Configuration; 6 | using System.IO; 7 | using System.Net; 8 | using System.Net.NetworkInformation; 9 | using System.Runtime.InteropServices; 10 | using System.Management; 11 | using System.Resources; 12 | 13 | 14 | namespace gui 15 | { 16 | static class Program 17 | { 18 | /// 19 | /// 应用程序的主入口点。 20 | /// 21 | [STAThread] 22 | static void Main() 23 | { 24 | NetworkInterfaceAvaliable.List(); 25 | Application.EnableVisualStyles(); 26 | Application.SetCompatibleTextRenderingDefault(false); 27 | Cfg.Load(); 28 | Application.Run(new Form1()); 29 | RefComm.StopAuthThread(); 30 | return; 31 | } 32 | 33 | } 34 | public class Cfg 35 | { 36 | public static string username; 37 | public static string password; 38 | public static string device; 39 | public static bool store = false; 40 | public static bool auto = false; 41 | public static int mode = 0; 42 | public static string versionHEX; // 十六进制表示的版本号 43 | public static string H3C_key; // H3C加密密钥 44 | public static void Load() 45 | { 46 | //加载配置文件 47 | try 48 | { 49 | ExeConfigurationFileMap map = new ExeConfigurationFileMap(); 50 | map.ExeConfigFilename = Application.StartupPath + "/NXSharp.exe.Config"; 51 | Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map,ConfigurationUserLevel.None); 52 | AppSettingsSection app = config.AppSettings; 53 | Cfg.username = app.Settings["username"].Value; 54 | Cfg.password = app.Settings["password"].Value; 55 | Cfg.device = app.Settings["device"].Value; 56 | Cfg.store = Convert.ToBoolean(app.Settings["store"].Value); 57 | Cfg.auto = Convert.ToBoolean(app.Settings["auto"].Value); 58 | Cfg.mode = Convert.ToInt32(app.Settings["mode"].Value); 59 | Cfg.versionHEX = app.Settings["versionHEX"].Value; 60 | Cfg.H3C_key = app.Settings["H3C_key"].Value; 61 | return; 62 | } 63 | catch (Exception) 64 | { 65 | //避免配置文件丢失 66 | MessageBox.Show("没有找到配置文件!"); 67 | return; 68 | } 69 | } 70 | public static void Commit() 71 | { 72 | //提交配置文件修改 73 | ExeConfigurationFileMap map = new ExeConfigurationFileMap(); 74 | map.ExeConfigFilename = Application.StartupPath + "/NXSharp.exe.Config"; 75 | Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); 76 | AppSettingsSection app = config.AppSettings; 77 | app.Settings["username"].Value = username; 78 | app.Settings["password"].Value = password; 79 | app.Settings["device"].Value = device; 80 | app.Settings["store"].Value = store.ToString(); 81 | app.Settings["auto"].Value = auto.ToString(); 82 | app.Settings["mode"].Value = mode.ToString(); 83 | app.Settings["versionHEX"].Value = versionHEX; 84 | app.Settings["H3C_key"].Value = H3C_key; 85 | config.Save(); 86 | return; 87 | } 88 | public static string VersionParser(string HEXversion) 89 | { 90 | // 将16进制版本号转换为实际值 91 | char[] CHARversion = new char[16]; 92 | string[] str = new string[16]; 93 | for (int i = 0; i < HEXversion.Length / 2; i = i + 1) 94 | { 95 | str[i] = HEXversion.Substring(i * 2, 2); 96 | CHARversion[i] = (char)Convert.ToInt32(str[i], 16); 97 | } 98 | return new string(CHARversion); 99 | } 100 | } 101 | public class NetworkInterfaceAvaliable 102 | { 103 | public static Dictionary adapters_dict = new Dictionary(); 104 | public static void List() 105 | { 106 | NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); 107 | foreach (NetworkInterface adapter in adapters) 108 | { 109 | //if (adapter.NetworkInterfaceType.ToString() == "Ethernet") 110 | //{ 111 | NetworkInterfaceAvaliable.adapters_dict.Add(adapter.Description, adapter.Id); 112 | //} 113 | } 114 | } 115 | public static void RefreshDHCP(string device_id) 116 | { 117 | //需要手动添加对 System.Management 的引用 118 | ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration"); 119 | ManagementObjectCollection objMOC = objMC.GetInstances(); 120 | foreach (ManagementObject objMO in objMOC) 121 | { 122 | //Need to determine which adapter here with some kind of if() statement 123 | if (objMO["SettingID"].ToString() == device_id) 124 | { 125 | objMO.InvokeMethod("ReleaseDHCPLease", null, null); 126 | objMO.InvokeMethod("RenewDHCPLease", null, null); 127 | } 128 | } 129 | } 130 | } 131 | 132 | public class RefComm 133 | { 134 | [DllImport("xclient.dll", EntryPoint = "StartAuthThread", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] 135 | public static extern void StartAuthThread(string username, string password, string device, string version, string H3C_key, int mode_config); 136 | [DllImport("xclient.dll", EntryPoint = "StopAuthThread", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] 137 | public static extern void StopAuthThread(); 138 | [DllImport("xclient.dll", EntryPoint = "ReadLog", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] 139 | private static extern IntPtr GetLogBuffer(); 140 | public static string ReadLog() 141 | { 142 | return Marshal.PtrToStringAnsi(GetLogBuffer()); 143 | } 144 | 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Nxsharp/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Net; 9 | using System.Net.NetworkInformation; 10 | using global::System.Windows.Forms; 11 | using System.IO; 12 | using Microsoft.Win32; 13 | 14 | namespace gui 15 | { 16 | public partial class Form1:Form 17 | { 18 | StringBuilder outSb = new StringBuilder(); 19 | public Form1() 20 | { 21 | InitializeComponent(); 22 | this.textBox1.Text = Cfg.username; 23 | this.textBox2.Text = Cfg.password; 24 | this.comboBox1.Text = Cfg.device; 25 | this.checkBox1.Checked = Cfg.store; 26 | this.checkBox2.Checked = Cfg.auto; 27 | 28 | foreach (string adapter in NetworkInterfaceAvaliable.adapters_dict.Keys) 29 | { 30 | this.comboBox1.Items.Add(adapter); 31 | } 32 | if (NetworkInterfaceAvaliable.adapters_dict.ContainsKey(Cfg.device)) 33 | { 34 | this.comboBox1.Text = Cfg.device; 35 | } 36 | else 37 | { 38 | this.comboBox1.Text = this.comboBox1.Items[0].ToString(); 39 | } 40 | if (Cfg.auto) 41 | { 42 | button1_Click(button1, new EventArgs()); 43 | } 44 | SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(OnPowerModeChanged); 45 | 46 | } 47 | private void button3_Click(object sender, EventArgs e) 48 | { 49 | Form2 f2 = new Form2(); 50 | f2.ShowDialog(); 51 | } 52 | 53 | public void button1_Click(object sender, EventArgs e) 54 | { 55 | Cfg.username = textBox1.Text; 56 | Cfg.password = textBox2.Text; 57 | Cfg.device = comboBox1.Text; 58 | Cfg.store = checkBox1.Checked; 59 | Cfg.auto = checkBox2.Checked; 60 | if(checkBox1.Checked) 61 | { 62 | Cfg.Commit(); 63 | } 64 | else 65 | { 66 | Cfg.username = null; 67 | Cfg.password = null; 68 | Cfg.store = false; 69 | Cfg.auto = false; 70 | Cfg.Commit(); 71 | } 72 | RefComm.StartAuthThread(Cfg.username, Cfg.password, "\\Device\\NPF_" + NetworkInterfaceAvaliable.adapters_dict[Cfg.device], Cfg.VersionParser(Cfg.versionHEX), Cfg.H3C_key, Cfg.mode); 73 | button1.Enabled = false; 74 | button2.Enabled = true; 75 | panel1.Enabled = false; 76 | textBox3.Text = ""; 77 | timer1.Enabled = true; 78 | } 79 | 80 | private void checkBox1_CheckedChanged(object sender, EventArgs e) 81 | { 82 | if(checkBox1.Checked) 83 | { 84 | checkBox2.Enabled = true; 85 | } 86 | else 87 | { 88 | checkBox2.Enabled = false; 89 | checkBox2.Checked = false; 90 | } 91 | } 92 | 93 | 94 | private void button2_Click(object sender, EventArgs e) 95 | { 96 | RefComm.StopAuthThread(); 97 | panel1.Enabled = true; 98 | button1.Enabled = true; 99 | button2.Enabled = false; 100 | textBox3.AppendText("\r\n已登出"); 101 | timer1.Enabled = false; 102 | } 103 | 104 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) 105 | { 106 | Cfg.device = comboBox1.Text; 107 | } 108 | private void refreshText() 109 | { 110 | string tmp = RefComm.ReadLog(); 111 | 112 | 113 | 114 | if (tmp.Length != 0) 115 | { 116 | if (textBox3.Text.Length > 1024) 117 | { 118 | textBox3.Text = ""; 119 | textBox3.ScrollToCaret(); 120 | } 121 | textBox3.ScrollToCaret();//自动滚屏 122 | textBox3.AppendText(tmp); 123 | textBox3.ScrollToCaret(); 124 | } 125 | //自动更新IP 126 | if (tmp.Contains("Success")) 127 | { 128 | NetworkInterfaceAvaliable.RefreshDHCP(NetworkInterfaceAvaliable.adapters_dict[comboBox1.Text]); 129 | textBox3.AppendText("IP Refreshed.\r\n"); 130 | textBox3.ScrollToCaret();//自动滚屏 131 | } 132 | 133 | } 134 | 135 | private void Form1_Deactivate(object sender, EventArgs e) 136 | { 137 | if (this.WindowState == FormWindowState.Minimized) 138 | { 139 | this.ShowInTaskbar = false; 140 | this.Hide(); 141 | notifyIcon1.ShowBalloonTip(1000, "", "NXSharp正在运行!", ToolTipIcon.Warning); 142 | } 143 | } 144 | 145 | 146 | 147 | private void Form1_Activated(object sender, EventArgs e) 148 | { 149 | textBox3.ScrollToCaret();//自动滚屏到最下 150 | } 151 | private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e) 152 | { 153 | if (button1.Enabled == false && button2.Enabled == true) //判断是否点击登录 154 | { 155 | switch (e.Mode) 156 | { 157 | //系统挂起 158 | case PowerModes.Suspend: 159 | RefComm.StopAuthThread(); 160 | textBox3.AppendText("\r\n已登出"); 161 | break; 162 | //系统恢复 163 | case PowerModes.Resume: 164 | RefComm.StartAuthThread(Cfg.username, Cfg.password, "\\Device\\NPF_" + NetworkInterfaceAvaliable.adapters_dict[Cfg.device], Cfg.VersionParser(Cfg.versionHEX), Cfg.H3C_key, Cfg.mode); 165 | break; 166 | } 167 | } 168 | 169 | } 170 | 171 | private void timer1_Tick(object sender, EventArgs e) 172 | { 173 | refreshText(); 174 | } 175 | 176 | private void notifyIcon1_Click(object sender, EventArgs e) 177 | { 178 | this.Show(); 179 | this.ShowInTaskbar = true; 180 | this.WindowState = FormWindowState.Normal; 181 | this.BringToFront(); 182 | } 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /Nxsharp/Form2.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | njit8021xclient-sharp 122 | 兼容 CH V7.10-0313 123 | 124 | 常见问题: 125 | 0. 出现错误“stop connection 0x08” 126 | 进入“本地连接>属性>身份验证”选项卡,检查是否启用了802.1x验证。请务必保持其关闭状态! 127 | 检查是否安装有360wifi。如果有请将其卸载或者换用猎豹wifi及wifi共享精灵等。这是一个未知问题,似乎360wifi的驱动机制会干扰认证进行,希望有人能向360wifi官方反映情况。 128 | 1.无法运行? 129 | 请确认已安装 .net framework 3.5 130 | 2.提示系统找不到指定的设备? 131 | 请确认已安装winpcap。 132 | 3.登录停留在“Client:Start”? 133 | 请确认网线连接正确,网卡选择正确。 134 | 4.“Client:Start”重复出现? 135 | 请重启电脑 136 | 5.登陆成功,但没有获取IP地址? 137 | 请点击“手动刷新IP地址” 138 | 6.登陆成功,获取IP正确,但没有连接? 139 | 重启电脑,或手动禁用网卡后启用之。 140 | 7.360提示程序可疑? 141 | 卸了360 142 | 143 | 注意: 144 | 本工具在njit8021xclient项目基础上开发,遵循GPLv3协议开源,代码托管于github: 145 | https://github.com/bitdust/nxsharp 146 | 147 | -------------------------------------------------------------------------------- /Nxsharp/nxsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D561E655-72C1-43B9-8BF8-1775BE56CF6F} 8 | WinExe 9 | Properties 10 | gui 11 | NXSharp 12 | v3.5 13 | 512 14 | false 15 | 16 | 发布\ 17 | true 18 | Disk 19 | false 20 | Foreground 21 | 7 22 | Days 23 | false 24 | false 25 | true 26 | 0 27 | 1.0.0.%2a 28 | false 29 | true 30 | 31 | 32 | x86 33 | true 34 | full 35 | false 36 | ..\Debug\ 37 | DEBUG;TRACE 38 | prompt 39 | 4 40 | false 41 | 42 | 43 | AnyCPU 44 | pdbonly 45 | true 46 | bin\Release\ 47 | TRACE 48 | prompt 49 | 4 50 | false 51 | 52 | 53 | x86 54 | ..\Debug\ 55 | TRACE;DEBUG 56 | false 57 | 58 | 59 | x86 60 | ..\Release\ 61 | false 62 | 63 | 64 | 65 | 66 | 67 | iNode ClientR.ico 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Form 86 | 87 | 88 | Form1.cs 89 | 90 | 91 | Form 92 | 93 | 94 | Form2.cs 95 | 96 | 97 | Form 98 | 99 | 100 | Form3.cs 101 | 102 | 103 | 104 | 105 | Form1.cs 106 | 107 | 108 | Form2.cs 109 | 110 | 111 | Form3.cs 112 | 113 | 114 | ResXFileCodeGenerator 115 | Resources.Designer.cs 116 | Designer 117 | 118 | 119 | True 120 | Resources.resx 121 | True 122 | 123 | 124 | Designer 125 | 126 | 127 | SettingsSingleFileGenerator 128 | Settings.Designer.cs 129 | 130 | 131 | True 132 | Settings.settings 133 | True 134 | 135 | 136 | 137 | 138 | False 139 | .NET Framework 3.5 SP1 Client Profile 140 | false 141 | 142 | 143 | False 144 | .NET Framework 3.5 SP1 145 | true 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 161 | -------------------------------------------------------------------------------- /Nxsharp/Form2.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace gui 2 | { 3 | partial class Form2 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form2)); 32 | this.button3 = new System.Windows.Forms.Button(); 33 | this.button1 = new System.Windows.Forms.Button(); 34 | this.textBox1 = new System.Windows.Forms.TextBox(); 35 | this.linkLabel1 = new System.Windows.Forms.LinkLabel(); 36 | this.modeButton1 = new System.Windows.Forms.RadioButton(); 37 | this.modeButton2 = new System.Windows.Forms.RadioButton(); 38 | this.modeButton3 = new System.Windows.Forms.RadioButton(); 39 | this.label1 = new System.Windows.Forms.Label(); 40 | this.SuspendLayout(); 41 | // 42 | // button3 43 | // 44 | this.button3.Location = new System.Drawing.Point(212, 251); 45 | this.button3.Name = "button3"; 46 | this.button3.Size = new System.Drawing.Size(100, 23); 47 | this.button3.TabIndex = 0; 48 | this.button3.Text = "修改版本号&V"; 49 | this.button3.UseVisualStyleBackColor = true; 50 | this.button3.Click += new System.EventHandler(this.button3_Click); 51 | // 52 | // button1 53 | // 54 | this.button1.Location = new System.Drawing.Point(212, 222); 55 | this.button1.Name = "button1"; 56 | this.button1.Size = new System.Drawing.Size(100, 23); 57 | this.button1.TabIndex = 2; 58 | this.button1.Text = "手动刷新&IP"; 59 | this.button1.UseVisualStyleBackColor = true; 60 | this.button1.Click += new System.EventHandler(this.button1_Click); 61 | // 62 | // textBox1 63 | // 64 | this.textBox1.Location = new System.Drawing.Point(12, 12); 65 | this.textBox1.Multiline = true; 66 | this.textBox1.Name = "textBox1"; 67 | this.textBox1.ReadOnly = true; 68 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 69 | this.textBox1.Size = new System.Drawing.Size(300, 174); 70 | this.textBox1.TabIndex = 1; 71 | this.textBox1.TabStop = false; 72 | this.textBox1.Text = resources.GetString("textBox1.Text"); 73 | // 74 | // linkLabel1 75 | // 76 | this.linkLabel1.AutoSize = true; 77 | this.linkLabel1.Location = new System.Drawing.Point(232, 207); 78 | this.linkLabel1.Name = "linkLabel1"; 79 | this.linkLabel1.Size = new System.Drawing.Size(65, 12); 80 | this.linkLabel1.TabIndex = 4; 81 | this.linkLabel1.TabStop = true; 82 | this.linkLabel1.Text = "看看新版本"; 83 | this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); 84 | // 85 | // modeButton1 86 | // 87 | this.modeButton1.AutoSize = true; 88 | this.modeButton1.Location = new System.Drawing.Point(107, 207); 89 | this.modeButton1.Name = "modeButton1"; 90 | this.modeButton1.Size = new System.Drawing.Size(95, 16); 91 | this.modeButton1.TabIndex = 5; 92 | this.modeButton1.TabStop = true; 93 | this.modeButton1.Text = "掉线就掉线了"; 94 | this.modeButton1.UseVisualStyleBackColor = true; 95 | this.modeButton1.Visible = false; 96 | this.modeButton1.CheckedChanged += new System.EventHandler(this.modeButton1_CheckedChanged); 97 | // 98 | // modeButton2 99 | // 100 | this.modeButton2.AutoSize = true; 101 | this.modeButton2.Location = new System.Drawing.Point(30, 220); 102 | this.modeButton2.Name = "modeButton2"; 103 | this.modeButton2.Size = new System.Drawing.Size(71, 16); 104 | this.modeButton2.TabIndex = 6; 105 | this.modeButton2.TabStop = true; 106 | this.modeButton2.Text = "掉线重连"; 107 | this.modeButton2.UseVisualStyleBackColor = true; 108 | this.modeButton2.CheckedChanged += new System.EventHandler(this.modeButton2_CheckedChanged); 109 | // 110 | // modeButton3 111 | // 112 | this.modeButton3.AutoSize = true; 113 | this.modeButton3.Location = new System.Drawing.Point(30, 242); 114 | this.modeButton3.Name = "modeButton3"; 115 | this.modeButton3.Size = new System.Drawing.Size(155, 16); 116 | this.modeButton3.TabIndex = 7; 117 | this.modeButton3.TabStop = true; 118 | this.modeButton3.Text = "止痛药(每10分钟掉线!)"; 119 | this.modeButton3.UseVisualStyleBackColor = true; 120 | this.modeButton3.CheckedChanged += new System.EventHandler(this.modeButton3_CheckedChanged); 121 | // 122 | // label1 123 | // 124 | this.label1.AutoSize = true; 125 | this.label1.Location = new System.Drawing.Point(12, 193); 126 | this.label1.Name = "label1"; 127 | this.label1.Size = new System.Drawing.Size(89, 12); 128 | this.label1.TabIndex = 8; 129 | this.label1.Text = "工作模式选择:"; 130 | // 131 | // Form2 132 | // 133 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 134 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 135 | this.ClientSize = new System.Drawing.Size(324, 285); 136 | this.Controls.Add(this.label1); 137 | this.Controls.Add(this.modeButton3); 138 | this.Controls.Add(this.modeButton2); 139 | this.Controls.Add(this.modeButton1); 140 | this.Controls.Add(this.linkLabel1); 141 | this.Controls.Add(this.textBox1); 142 | this.Controls.Add(this.button1); 143 | this.Controls.Add(this.button3); 144 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 145 | this.MaximizeBox = false; 146 | this.MinimizeBox = false; 147 | this.Name = "Form2"; 148 | this.Text = "高级"; 149 | this.Load += new System.EventHandler(this.Form2_Load); 150 | this.ResumeLayout(false); 151 | this.PerformLayout(); 152 | 153 | } 154 | 155 | #endregion 156 | 157 | private System.Windows.Forms.Button button3; 158 | private System.Windows.Forms.Button button1; 159 | private System.Windows.Forms.TextBox textBox1; 160 | private System.Windows.Forms.LinkLabel linkLabel1; 161 | private System.Windows.Forms.RadioButton modeButton1; 162 | private System.Windows.Forms.RadioButton modeButton2; 163 | private System.Windows.Forms.RadioButton modeButton3; 164 | private System.Windows.Forms.Label label1; 165 | 166 | } 167 | } -------------------------------------------------------------------------------- /Nxsharp/Form3.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace gui 2 | { 3 | partial class Form3 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.textBox1 = new System.Windows.Forms.TextBox(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.textBox2 = new System.Windows.Forms.TextBox(); 35 | this.button1 = new System.Windows.Forms.Button(); 36 | this.label3 = new System.Windows.Forms.Label(); 37 | this.linkLabel1 = new System.Windows.Forms.LinkLabel(); 38 | this.textBox3 = new System.Windows.Forms.TextBox(); 39 | this.label4 = new System.Windows.Forms.Label(); 40 | this.label5 = new System.Windows.Forms.Label(); 41 | this.textBox4 = new System.Windows.Forms.TextBox(); 42 | this.SuspendLayout(); 43 | // 44 | // label1 45 | // 46 | this.label1.AutoSize = true; 47 | this.label1.Location = new System.Drawing.Point(10, 9); 48 | this.label1.Name = "label1"; 49 | this.label1.Size = new System.Drawing.Size(149, 12); 50 | this.label1.TabIndex = 0; 51 | this.label1.Text = "输入版本号(16进制表示)"; 52 | // 53 | // textBox1 54 | // 55 | this.textBox1.Location = new System.Drawing.Point(12, 24); 56 | this.textBox1.Name = "textBox1"; 57 | this.textBox1.Size = new System.Drawing.Size(188, 21); 58 | this.textBox1.TabIndex = 1; 59 | // 60 | // label2 61 | // 62 | this.label2.AutoSize = true; 63 | this.label2.Location = new System.Drawing.Point(10, 87); 64 | this.label2.Name = "label2"; 65 | this.label2.Size = new System.Drawing.Size(143, 12); 66 | this.label2.TabIndex = 2; 67 | this.label2.Text = "当前版本号(ASCII表示)"; 68 | // 69 | // textBox2 70 | // 71 | this.textBox2.Location = new System.Drawing.Point(12, 102); 72 | this.textBox2.Name = "textBox2"; 73 | this.textBox2.ReadOnly = true; 74 | this.textBox2.Size = new System.Drawing.Size(188, 21); 75 | this.textBox2.TabIndex = 3; 76 | // 77 | // button1 78 | // 79 | this.button1.Location = new System.Drawing.Point(56, 215); 80 | this.button1.Name = "button1"; 81 | this.button1.Size = new System.Drawing.Size(85, 23); 82 | this.button1.TabIndex = 4; 83 | this.button1.Text = "应用"; 84 | this.button1.UseVisualStyleBackColor = true; 85 | this.button1.Click += new System.EventHandler(this.button1_Click); 86 | // 87 | // label3 88 | // 89 | this.label3.AutoSize = true; 90 | this.label3.Location = new System.Drawing.Point(10, 176); 91 | this.label3.Name = "label3"; 92 | this.label3.Size = new System.Drawing.Size(197, 12); 93 | this.label3.TabIndex = 5; 94 | this.label3.Text = "非懂勿改!版本号与密钥获取方法见"; 95 | // 96 | // linkLabel1 97 | // 98 | this.linkLabel1.AutoSize = true; 99 | this.linkLabel1.Location = new System.Drawing.Point(70, 188); 100 | this.linkLabel1.Name = "linkLabel1"; 101 | this.linkLabel1.Size = new System.Drawing.Size(71, 12); 102 | this.linkLabel1.TabIndex = 6; 103 | this.linkLabel1.TabStop = true; 104 | this.linkLabel1.Text = "H3C_toolkit"; 105 | this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); 106 | // 107 | // textBox3 108 | // 109 | this.textBox3.Location = new System.Drawing.Point(12, 63); 110 | this.textBox3.Name = "textBox3"; 111 | this.textBox3.Size = new System.Drawing.Size(188, 21); 112 | this.textBox3.TabIndex = 1; 113 | // 114 | // label4 115 | // 116 | this.label4.AutoSize = true; 117 | this.label4.Location = new System.Drawing.Point(10, 48); 118 | this.label4.Name = "label4"; 119 | this.label4.Size = new System.Drawing.Size(149, 12); 120 | this.label4.TabIndex = 0; 121 | this.label4.Text = "输入H3C密钥(ASCII表示)"; 122 | // 123 | // label5 124 | // 125 | this.label5.AutoSize = true; 126 | this.label5.Location = new System.Drawing.Point(10, 126); 127 | this.label5.Name = "label5"; 128 | this.label5.Size = new System.Drawing.Size(131, 12); 129 | this.label5.TabIndex = 2; 130 | this.label5.Text = "当前密钥(ASCII表示)"; 131 | // 132 | // textBox4 133 | // 134 | this.textBox4.Location = new System.Drawing.Point(12, 141); 135 | this.textBox4.Name = "textBox4"; 136 | this.textBox4.ReadOnly = true; 137 | this.textBox4.Size = new System.Drawing.Size(188, 21); 138 | this.textBox4.TabIndex = 3; 139 | // 140 | // Form3 141 | // 142 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 143 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 144 | this.ClientSize = new System.Drawing.Size(212, 250); 145 | this.Controls.Add(this.linkLabel1); 146 | this.Controls.Add(this.label3); 147 | this.Controls.Add(this.button1); 148 | this.Controls.Add(this.textBox4); 149 | this.Controls.Add(this.textBox2); 150 | this.Controls.Add(this.label5); 151 | this.Controls.Add(this.label2); 152 | this.Controls.Add(this.textBox3); 153 | this.Controls.Add(this.textBox1); 154 | this.Controls.Add(this.label4); 155 | this.Controls.Add(this.label1); 156 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 157 | this.MaximizeBox = false; 158 | this.MinimizeBox = false; 159 | this.Name = "Form3"; 160 | this.ShowIcon = false; 161 | this.ShowInTaskbar = false; 162 | this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; 163 | this.Text = "修改版本号"; 164 | this.ResumeLayout(false); 165 | this.PerformLayout(); 166 | 167 | } 168 | 169 | #endregion 170 | 171 | private System.Windows.Forms.Label label1; 172 | private System.Windows.Forms.TextBox textBox1; 173 | private System.Windows.Forms.Label label2; 174 | private System.Windows.Forms.TextBox textBox2; 175 | private System.Windows.Forms.Button button1; 176 | private System.Windows.Forms.Label label3; 177 | private System.Windows.Forms.LinkLabel linkLabel1; 178 | private System.Windows.Forms.TextBox textBox3; 179 | private System.Windows.Forms.Label label4; 180 | private System.Windows.Forms.Label label5; 181 | private System.Windows.Forms.TextBox textBox4; 182 | } 183 | } -------------------------------------------------------------------------------- /src/md5/md5.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // The original file was copied from sqlite, and was in the public domain. 6 | 7 | /* 8 | * This code implements the MD5 message-digest algorithm. 9 | * The algorithm is due to Ron Rivest. This code was 10 | * written by Colin Plumb in 1993, no copyright is claimed. 11 | * This code is in the public domain; do with it what you wish. 12 | * 13 | * Equivalent code is available from RSA Data Security, Inc. 14 | * This code has been tested against that, and is equivalent, 15 | * except that you don't need to include two pages of legalese 16 | * with every copy. 17 | * 18 | * To compute the message digest of a chunk of bytes, declare an 19 | * MD5Context structure, pass it to MD5Init, call MD5Update as 20 | * needed on buffers full of bytes, and then call MD5Final, which 21 | * will fill a supplied 16-byte array with the digest. 22 | */ 23 | 24 | #ifndef WIN32 25 | #include 26 | #endif 27 | #include 28 | #include 29 | 30 | #include "md5.h" 31 | 32 | typedef uint32_t uint32; 33 | 34 | struct Context { 35 | uint32 buf[4]; 36 | uint32 bits[2]; 37 | unsigned char in[64]; 38 | }; 39 | 40 | /* 41 | * Note: this code is harmless on little-endian machines. 42 | */ 43 | void byteReverse(unsigned char *buf, unsigned longs) { 44 | uint32 t; 45 | do { 46 | t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 | 47 | ((unsigned)buf[1]<<8 | buf[0]); 48 | *(uint32 *)buf = t; 49 | buf += 4; 50 | } while (--longs); 51 | } 52 | 53 | /* The four core functions - F1 is optimized somewhat */ 54 | 55 | /* #define F1(x, y, z) (x & y | ~x & z) */ 56 | #define F1(x, y, z) (z ^ (x & (y ^ z))) 57 | #define F2(x, y, z) F1(z, x, y) 58 | #define F3(x, y, z) (x ^ y ^ z) 59 | #define F4(x, y, z) (y ^ (x | ~z)) 60 | 61 | /* This is the central step in the MD5 algorithm. */ 62 | #define MD5STEP(f, w, x, y, z, data, s) \ 63 | ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) 64 | 65 | /* 66 | * The core of the MD5 algorithm, this alters an existing MD5 hash to 67 | * reflect the addition of 16 longwords of new data. MD5Update blocks 68 | * the data and converts bytes into longwords for this routine. 69 | */ 70 | void MD5Transform(uint32 buf[4], const uint32 in[16]) { 71 | register uint32 a, b, c, d; 72 | 73 | a = buf[0]; 74 | b = buf[1]; 75 | c = buf[2]; 76 | d = buf[3]; 77 | 78 | MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7); 79 | MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12); 80 | MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17); 81 | MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22); 82 | MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7); 83 | MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12); 84 | MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17); 85 | MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22); 86 | MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7); 87 | MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12); 88 | MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17); 89 | MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22); 90 | MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7); 91 | MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12); 92 | MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17); 93 | MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22); 94 | 95 | MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5); 96 | MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9); 97 | MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14); 98 | MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20); 99 | MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5); 100 | MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9); 101 | MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14); 102 | MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20); 103 | MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5); 104 | MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9); 105 | MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14); 106 | MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20); 107 | MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5); 108 | MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9); 109 | MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14); 110 | MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20); 111 | 112 | MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4); 113 | MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11); 114 | MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16); 115 | MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23); 116 | MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4); 117 | MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11); 118 | MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16); 119 | MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23); 120 | MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4); 121 | MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11); 122 | MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16); 123 | MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23); 124 | MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4); 125 | MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11); 126 | MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16); 127 | MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23); 128 | 129 | MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6); 130 | MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10); 131 | MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15); 132 | MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21); 133 | MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6); 134 | MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10); 135 | MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15); 136 | MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21); 137 | MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6); 138 | MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10); 139 | MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15); 140 | MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21); 141 | MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6); 142 | MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10); 143 | MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15); 144 | MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21); 145 | 146 | buf[0] += a; 147 | buf[1] += b; 148 | buf[2] += c; 149 | buf[3] += d; 150 | } 151 | 152 | 153 | /* 154 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious 155 | * initialization constants. 156 | */ 157 | void MD5Init(MD5Context* context) { 158 | struct Context *ctx = (struct Context *)context; 159 | ctx->buf[0] = 0x67452301; 160 | ctx->buf[1] = 0xefcdab89; 161 | ctx->buf[2] = 0x98badcfe; 162 | ctx->buf[3] = 0x10325476; 163 | ctx->bits[0] = 0; 164 | ctx->bits[1] = 0; 165 | } 166 | 167 | /* 168 | * Update context to reflect the concatenation of another buffer full 169 | * of bytes. 170 | */ 171 | void MD5Update(MD5Context* context, const unsigned char *data, size_t length) /*const StringPiece& data)*/ 172 | { 173 | const unsigned char* inbuf = data; //(const unsigned char*)data.data(); 174 | size_t len = length; //data.size(); 175 | struct Context *ctx = (struct Context *)context; 176 | const unsigned char* buf = (const unsigned char*)inbuf; 177 | uint32 t; 178 | 179 | /* Update bitcount */ 180 | 181 | t = ctx->bits[0]; 182 | if ((ctx->bits[0] = t + ((uint32)len << 3)) < t) 183 | ctx->bits[1]++; /* Carry from low to high */ 184 | ctx->bits[1] += (uint32)(len >> 29); //static_cast(len >> 29); 185 | 186 | t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ 187 | 188 | /* Handle any leading odd-sized chunks */ 189 | 190 | if (t) { 191 | unsigned char *p = (unsigned char *)ctx->in + t; 192 | 193 | t = 64-t; 194 | if (len < t) { 195 | memcpy(p, buf, len); 196 | return; 197 | } 198 | memcpy(p, buf, t); 199 | byteReverse(ctx->in, 16); 200 | MD5Transform(ctx->buf, (uint32 *)ctx->in); 201 | buf += t; 202 | len -= t; 203 | } 204 | 205 | /* Process data in 64-byte chunks */ 206 | 207 | while (len >= 64) { 208 | memcpy(ctx->in, buf, 64); 209 | byteReverse(ctx->in, 16); 210 | MD5Transform(ctx->buf, (uint32 *)ctx->in); 211 | buf += 64; 212 | len -= 64; 213 | } 214 | 215 | /* Handle any remaining bytes of data. */ 216 | 217 | memcpy(ctx->in, buf, len); 218 | } 219 | 220 | /* 221 | * Final wrapup - pad to 64-byte boundary with the bit pattern 222 | * 1 0* (64-bit count of bits processed, MSB-first) 223 | */ 224 | void MD5Final(struct MD5Digest* digest, MD5Context* context) { 225 | struct Context *ctx = (struct Context *)context; 226 | unsigned count; 227 | unsigned char *p; 228 | 229 | /* Compute number of bytes mod 64 */ 230 | count = (ctx->bits[0] >> 3) & 0x3F; 231 | 232 | /* Set the first char of padding to 0x80. This is safe since there is 233 | always at least one byte free */ 234 | p = ctx->in + count; 235 | *p++ = 0x80; 236 | 237 | /* Bytes of padding needed to make 64 bytes */ 238 | count = 64 - 1 - count; 239 | 240 | /* Pad out to 56 mod 64 */ 241 | if (count < 8) { 242 | /* Two lots of padding: Pad the first block to 64 bytes */ 243 | memset(p, 0, count); 244 | byteReverse(ctx->in, 16); 245 | MD5Transform(ctx->buf, (uint32 *)ctx->in); 246 | 247 | /* Now fill the next block with 56 bytes */ 248 | memset(ctx->in, 0, 56); 249 | } else { 250 | /* Pad block to 56 bytes */ 251 | memset(p, 0, count-8); 252 | } 253 | byteReverse(ctx->in, 14); 254 | 255 | /* Append length in bits and transform */ 256 | ((uint32 *)ctx->in)[ 14 ] = ctx->bits[0]; 257 | ((uint32 *)ctx->in)[ 15 ] = ctx->bits[1]; 258 | 259 | MD5Transform(ctx->buf, (uint32 *)ctx->in); 260 | byteReverse((unsigned char *)ctx->buf, 4); 261 | memcpy(digest->a, ctx->buf, 16); 262 | memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ 263 | } 264 | 265 | 266 | void MD5Calc(unsigned char *data, unsigned int len, unsigned char *output) 267 | { 268 | MD5Context context; 269 | struct MD5Digest digest; 270 | 271 | MD5Init(&context); 272 | MD5Update(&context, (unsigned char *)data, len); 273 | MD5Final(&digest, &context); 274 | memcpy(output, digest.a, 16); 275 | } 276 | 277 | 278 | -------------------------------------------------------------------------------- /Nxsharp/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace gui 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows 窗体设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); 33 | this.button3 = new System.Windows.Forms.Button(); 34 | this.button2 = new System.Windows.Forms.Button(); 35 | this.button1 = new System.Windows.Forms.Button(); 36 | this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); 37 | this.textBox3 = new System.Windows.Forms.TextBox(); 38 | this.panel1 = new System.Windows.Forms.Panel(); 39 | this.checkBox2 = new System.Windows.Forms.CheckBox(); 40 | this.label3 = new System.Windows.Forms.Label(); 41 | this.checkBox1 = new System.Windows.Forms.CheckBox(); 42 | this.label2 = new System.Windows.Forms.Label(); 43 | this.label1 = new System.Windows.Forms.Label(); 44 | this.comboBox1 = new System.Windows.Forms.ComboBox(); 45 | this.textBox2 = new System.Windows.Forms.TextBox(); 46 | this.textBox1 = new System.Windows.Forms.TextBox(); 47 | this.timer1 = new System.Windows.Forms.Timer(this.components); 48 | this.panel1.SuspendLayout(); 49 | this.SuspendLayout(); 50 | // 51 | // button3 52 | // 53 | this.button3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button3.BackgroundImage"))); 54 | this.button3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; 55 | this.button3.Location = new System.Drawing.Point(14, 125); 56 | this.button3.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 57 | this.button3.Name = "button3"; 58 | this.button3.Size = new System.Drawing.Size(25, 25); 59 | this.button3.TabIndex = 8; 60 | this.button3.TabStop = false; 61 | this.button3.UseVisualStyleBackColor = true; 62 | this.button3.Click += new System.EventHandler(this.button3_Click); 63 | // 64 | // button2 65 | // 66 | this.button2.Enabled = false; 67 | this.button2.ForeColor = System.Drawing.SystemColors.ControlText; 68 | this.button2.Location = new System.Drawing.Point(129, 125); 69 | this.button2.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 70 | this.button2.Name = "button2"; 71 | this.button2.Size = new System.Drawing.Size(74, 25); 72 | this.button2.TabIndex = 7; 73 | this.button2.Text = "登出&O"; 74 | this.button2.UseVisualStyleBackColor = true; 75 | this.button2.Click += new System.EventHandler(this.button2_Click); 76 | // 77 | // button1 78 | // 79 | this.button1.Location = new System.Drawing.Point(47, 125); 80 | this.button1.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 81 | this.button1.Name = "button1"; 82 | this.button1.Size = new System.Drawing.Size(74, 25); 83 | this.button1.TabIndex = 6; 84 | this.button1.Text = "登录&L"; 85 | this.button1.UseVisualStyleBackColor = true; 86 | this.button1.Click += new System.EventHandler(this.button1_Click); 87 | // 88 | // notifyIcon1 89 | // 90 | this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); 91 | this.notifyIcon1.Text = "NX#"; 92 | this.notifyIcon1.Visible = true; 93 | this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click); 94 | // 95 | // textBox3 96 | // 97 | this.textBox3.BackColor = System.Drawing.SystemColors.ActiveCaptionText; 98 | this.textBox3.ForeColor = System.Drawing.Color.Lime; 99 | this.textBox3.Location = new System.Drawing.Point(11, 168); 100 | this.textBox3.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 101 | this.textBox3.Multiline = true; 102 | this.textBox3.Name = "textBox3"; 103 | this.textBox3.ReadOnly = true; 104 | this.textBox3.Size = new System.Drawing.Size(192, 143); 105 | this.textBox3.TabIndex = 16; 106 | this.textBox3.TabStop = false; 107 | this.textBox3.Text = "njit8021xclient-sharp\r\nver: 3.6 LOL\r\n\r\n完善对inode 7.1 E0313的支持。\r\n\r\n首次使用请安装Winpcap"; 108 | // 109 | // panel1 110 | // 111 | this.panel1.Controls.Add(this.checkBox2); 112 | this.panel1.Controls.Add(this.label3); 113 | this.panel1.Controls.Add(this.checkBox1); 114 | this.panel1.Controls.Add(this.label2); 115 | this.panel1.Controls.Add(this.label1); 116 | this.panel1.Controls.Add(this.comboBox1); 117 | this.panel1.Controls.Add(this.textBox2); 118 | this.panel1.Controls.Add(this.textBox1); 119 | this.panel1.Location = new System.Drawing.Point(-1, 0); 120 | this.panel1.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 121 | this.panel1.Name = "panel1"; 122 | this.panel1.Size = new System.Drawing.Size(217, 119); 123 | this.panel1.TabIndex = 17; 124 | // 125 | // checkBox2 126 | // 127 | this.checkBox2.AutoSize = true; 128 | this.checkBox2.Location = new System.Drawing.Point(132, 97); 129 | this.checkBox2.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 130 | this.checkBox2.Name = "checkBox2"; 131 | this.checkBox2.Size = new System.Drawing.Size(72, 16); 132 | this.checkBox2.TabIndex = 5; 133 | this.checkBox2.Text = "自动登录"; 134 | this.checkBox2.UseVisualStyleBackColor = true; 135 | // 136 | // label3 137 | // 138 | this.label3.AutoSize = true; 139 | this.label3.Location = new System.Drawing.Point(13, 75); 140 | this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 141 | this.label3.Name = "label3"; 142 | this.label3.Size = new System.Drawing.Size(29, 12); 143 | this.label3.TabIndex = 17; 144 | this.label3.Text = "网卡"; 145 | // 146 | // checkBox1 147 | // 148 | this.checkBox1.AutoSize = true; 149 | this.checkBox1.Location = new System.Drawing.Point(48, 97); 150 | this.checkBox1.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 151 | this.checkBox1.Name = "checkBox1"; 152 | this.checkBox1.Size = new System.Drawing.Size(72, 16); 153 | this.checkBox1.TabIndex = 4; 154 | this.checkBox1.Text = "保存信息"; 155 | this.checkBox1.UseVisualStyleBackColor = true; 156 | // 157 | // label2 158 | // 159 | this.label2.AutoSize = true; 160 | this.label2.Location = new System.Drawing.Point(13, 47); 161 | this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 162 | this.label2.Name = "label2"; 163 | this.label2.Size = new System.Drawing.Size(29, 12); 164 | this.label2.TabIndex = 19; 165 | this.label2.Text = "密码"; 166 | // 167 | // label1 168 | // 169 | this.label1.AutoSize = true; 170 | this.label1.Location = new System.Drawing.Point(13, 20); 171 | this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 172 | this.label1.Name = "label1"; 173 | this.label1.Size = new System.Drawing.Size(29, 12); 174 | this.label1.TabIndex = 21; 175 | this.label1.Text = "帐号"; 176 | // 177 | // comboBox1 178 | // 179 | this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 180 | this.comboBox1.DropDownWidth = 300; 181 | this.comboBox1.FormattingEnabled = true; 182 | this.comboBox1.Location = new System.Drawing.Point(48, 71); 183 | this.comboBox1.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 184 | this.comboBox1.Name = "comboBox1"; 185 | this.comboBox1.Size = new System.Drawing.Size(156, 20); 186 | this.comboBox1.TabIndex = 3; 187 | this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); 188 | // 189 | // textBox2 190 | // 191 | this.textBox2.Location = new System.Drawing.Point(48, 44); 192 | this.textBox2.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 193 | this.textBox2.Name = "textBox2"; 194 | this.textBox2.PasswordChar = '*'; 195 | this.textBox2.Size = new System.Drawing.Size(156, 21); 196 | this.textBox2.TabIndex = 2; 197 | // 198 | // textBox1 199 | // 200 | this.textBox1.Location = new System.Drawing.Point(48, 17); 201 | this.textBox1.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 202 | this.textBox1.Name = "textBox1"; 203 | this.textBox1.Size = new System.Drawing.Size(156, 21); 204 | this.textBox1.TabIndex = 1; 205 | // 206 | // timer1 207 | // 208 | this.timer1.Interval = 200; 209 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick); 210 | // 211 | // Form1 212 | // 213 | this.AcceptButton = this.button1; 214 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 215 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 216 | this.ClientSize = new System.Drawing.Size(214, 323); 217 | this.Controls.Add(this.textBox3); 218 | this.Controls.Add(this.panel1); 219 | this.Controls.Add(this.button3); 220 | this.Controls.Add(this.button2); 221 | this.Controls.Add(this.button1); 222 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 223 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 224 | this.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); 225 | this.MaximizeBox = false; 226 | this.Name = "Form1"; 227 | this.Text = "NX#"; 228 | this.Activated += new System.EventHandler(this.Form1_Activated); 229 | this.Deactivate += new System.EventHandler(this.Form1_Deactivate); 230 | this.panel1.ResumeLayout(false); 231 | this.panel1.PerformLayout(); 232 | this.ResumeLayout(false); 233 | this.PerformLayout(); 234 | 235 | } 236 | 237 | #endregion 238 | 239 | private System.Windows.Forms.Button button3; 240 | private System.Windows.Forms.Button button2; 241 | private System.Windows.Forms.Button button1; 242 | private System.Windows.Forms.NotifyIcon notifyIcon1; 243 | private System.Windows.Forms.TextBox textBox3; 244 | private System.Windows.Forms.Panel panel1; 245 | private System.Windows.Forms.CheckBox checkBox2; 246 | private System.Windows.Forms.Label label3; 247 | private System.Windows.Forms.CheckBox checkBox1; 248 | private System.Windows.Forms.Label label2; 249 | private System.Windows.Forms.Label label1; 250 | private System.Windows.Forms.ComboBox comboBox1; 251 | private System.Windows.Forms.TextBox textBox2; 252 | private System.Windows.Forms.TextBox textBox1; 253 | private System.Windows.Forms.Timer timer1; 254 | 255 | } 256 | } 257 | 258 | -------------------------------------------------------------------------------- /src/h3c_AES_MD5/aes.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This is an implementation of the AES128 algorithm, specifically ECB and CBC mode. 4 | 5 | The implementation is verified against the test vectors in: 6 | National Institute of Standards and Technology Special Publication 800-38A 2001 ED 7 | 8 | ECB-AES128 9 | ---------- 10 | 11 | plain-text: 12 | 6bc1bee22e409f96e93d7e117393172a 13 | ae2d8a571e03ac9c9eb76fac45af8e51 14 | 30c81c46a35ce411e5fbc1191a0a52ef 15 | f69f2445df4f9b17ad2b417be66c3710 16 | 17 | key: 18 | 2b7e151628aed2a6abf7158809cf4f3c 19 | 20 | resulting cipher 21 | 3ad77bb40d7a3660a89ecaf32466ef97 22 | f5d3d58503b9699de785895a96fdbaaf 23 | 43b1cd7f598ece23881b00e3ed030688 24 | 7b0c785e27e8ad3f8223207104725dd4 25 | 26 | 27 | NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0) 28 | You should pad the end of the string with zeros if this is not the case. 29 | 30 | */ 31 | 32 | 33 | /*****************************************************************************/ 34 | /* Includes: */ 35 | /*****************************************************************************/ 36 | #include 37 | #include // CBC mode, for memset 38 | #include "aes.h" 39 | 40 | 41 | /*****************************************************************************/ 42 | /* Defines: */ 43 | /*****************************************************************************/ 44 | // The number of columns comprising a state in AES. This is a constant in AES. Value=4 45 | #define Nb 4 46 | // The number of 32 bit words in a key. 47 | #define Nk 4 48 | // Key length in bytes [128 bit] 49 | #define KEYLEN 16 50 | // The number of rounds in AES Cipher. 51 | #define Nr 10 52 | 53 | // jcallan@github points out that declaring Multiply as a function 54 | // reduces code size considerably with the Keil ARM compiler. 55 | // See this link for more information: https://github.com/kokke/tiny-AES128-C/pull/3 56 | #ifndef MULTIPLY_AS_A_FUNCTION 57 | #define MULTIPLY_AS_A_FUNCTION 0 58 | #endif 59 | 60 | 61 | /*****************************************************************************/ 62 | /* Private variables: */ 63 | /*****************************************************************************/ 64 | // state - array holding the intermediate results during decryption. 65 | typedef uint8_t state_t[4][4]; 66 | static state_t* state; 67 | 68 | // The array that stores the round keys. 69 | static uint8_t RoundKey[176]; 70 | 71 | // The Key input to the AES Program 72 | static const uint8_t* Key; 73 | 74 | #if defined(CBC) && CBC 75 | // Initial Vector used only for CBC mode 76 | static uint8_t* Iv; 77 | #endif 78 | 79 | // The lookup-tables are marked const so they can be placed in read-only storage instead of RAM 80 | // The numbers below can be computed dynamically trading ROM for RAM - 81 | // This can be useful in (embedded) bootloader applications, where ROM is often limited. 82 | static const uint8_t sbox[256] = { 83 | //0 1 2 3 4 5 6 7 8 9 A B C D E F 84 | 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 85 | 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 86 | 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 87 | 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 88 | 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 89 | 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 90 | 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 91 | 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 92 | 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 93 | 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 94 | 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 95 | 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 96 | 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 97 | 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 98 | 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 99 | 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; 100 | 101 | static const uint8_t rsbox[256] = 102 | { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 103 | 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 104 | 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 105 | 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 106 | 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 107 | 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 108 | 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 109 | 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 110 | 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 111 | 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 112 | 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 113 | 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 114 | 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 115 | 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 116 | 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 117 | 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; 118 | 119 | 120 | // The round constant word array, Rcon[i], contains the values given by 121 | // x to th e power (i-1) being powers of x (x is denoted as {02}) in the field GF(2^8) 122 | // Note that i starts at 1, not 0). 123 | static const uint8_t Rcon[255] = { 124 | 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 125 | 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 126 | 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 127 | 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 128 | 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 129 | 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 130 | 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 131 | 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 132 | 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 133 | 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 134 | 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 135 | 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 136 | 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 137 | 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 138 | 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 139 | 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb }; 140 | 141 | 142 | /*****************************************************************************/ 143 | /* Private functions: */ 144 | /*****************************************************************************/ 145 | static uint8_t getSBoxValue(uint8_t num) 146 | { 147 | return sbox[num]; 148 | } 149 | 150 | static uint8_t getSBoxInvert(uint8_t num) 151 | { 152 | return rsbox[num]; 153 | } 154 | 155 | // This function produces Nb(Nr+1) round keys. The round keys are used in each round to decrypt the states. 156 | static void KeyExpansion(void) 157 | { 158 | uint32_t i, j, k; 159 | uint8_t tempa[4]; // Used for the column/row operations 160 | 161 | // The first round key is the key itself. 162 | for(i = 0; i < Nk; ++i) 163 | { 164 | RoundKey[(i * 4) + 0] = Key[(i * 4) + 0]; 165 | RoundKey[(i * 4) + 1] = Key[(i * 4) + 1]; 166 | RoundKey[(i * 4) + 2] = Key[(i * 4) + 2]; 167 | RoundKey[(i * 4) + 3] = Key[(i * 4) + 3]; 168 | } 169 | 170 | // All other round keys are found from the previous round keys. 171 | for(; (i < (Nb * (Nr + 1))); ++i) 172 | { 173 | for(j = 0; j < 4; ++j) 174 | { 175 | tempa[j]=RoundKey[(i-1) * 4 + j]; 176 | } 177 | if (i % Nk == 0) 178 | { 179 | // This function rotates the 4 bytes in a word to the left once. 180 | // [a0,a1,a2,a3] becomes [a1,a2,a3,a0] 181 | 182 | // Function RotWord() 183 | { 184 | k = tempa[0]; 185 | tempa[0] = tempa[1]; 186 | tempa[1] = tempa[2]; 187 | tempa[2] = tempa[3]; 188 | tempa[3] = k; 189 | } 190 | 191 | // SubWord() is a function that takes a four-byte input word and 192 | // applies the S-box to each of the four bytes to produce an output word. 193 | 194 | // Function Subword() 195 | { 196 | tempa[0] = getSBoxValue(tempa[0]); 197 | tempa[1] = getSBoxValue(tempa[1]); 198 | tempa[2] = getSBoxValue(tempa[2]); 199 | tempa[3] = getSBoxValue(tempa[3]); 200 | } 201 | 202 | tempa[0] = tempa[0] ^ Rcon[i/Nk]; 203 | } 204 | else if (Nk > 6 && i % Nk == 4) 205 | { 206 | // Function Subword() 207 | { 208 | tempa[0] = getSBoxValue(tempa[0]); 209 | tempa[1] = getSBoxValue(tempa[1]); 210 | tempa[2] = getSBoxValue(tempa[2]); 211 | tempa[3] = getSBoxValue(tempa[3]); 212 | } 213 | } 214 | RoundKey[i * 4 + 0] = RoundKey[(i - Nk) * 4 + 0] ^ tempa[0]; 215 | RoundKey[i * 4 + 1] = RoundKey[(i - Nk) * 4 + 1] ^ tempa[1]; 216 | RoundKey[i * 4 + 2] = RoundKey[(i - Nk) * 4 + 2] ^ tempa[2]; 217 | RoundKey[i * 4 + 3] = RoundKey[(i - Nk) * 4 + 3] ^ tempa[3]; 218 | } 219 | } 220 | 221 | // This function adds the round key to state. 222 | // The round key is added to the state by an XOR function. 223 | static void AddRoundKey(uint8_t round) 224 | { 225 | uint8_t i,j; 226 | for(i=0;i<4;++i) 227 | { 228 | for(j = 0; j < 4; ++j) 229 | { 230 | (*state)[i][j] ^= RoundKey[round * Nb * 4 + i * Nb + j]; 231 | } 232 | } 233 | } 234 | 235 | // The SubBytes Function Substitutes the values in the 236 | // state matrix with values in an S-box. 237 | static void SubBytes(void) 238 | { 239 | uint8_t i, j; 240 | for(i = 0; i < 4; ++i) 241 | { 242 | for(j = 0; j < 4; ++j) 243 | { 244 | (*state)[j][i] = getSBoxValue((*state)[j][i]); 245 | } 246 | } 247 | } 248 | 249 | // The ShiftRows() function shifts the rows in the state to the left. 250 | // Each row is shifted with different offset. 251 | // Offset = Row number. So the first row is not shifted. 252 | static void ShiftRows(void) 253 | { 254 | uint8_t temp; 255 | 256 | // Rotate first row 1 columns to left 257 | temp = (*state)[0][1]; 258 | (*state)[0][1] = (*state)[1][1]; 259 | (*state)[1][1] = (*state)[2][1]; 260 | (*state)[2][1] = (*state)[3][1]; 261 | (*state)[3][1] = temp; 262 | 263 | // Rotate second row 2 columns to left 264 | temp = (*state)[0][2]; 265 | (*state)[0][2] = (*state)[2][2]; 266 | (*state)[2][2] = temp; 267 | 268 | temp = (*state)[1][2]; 269 | (*state)[1][2] = (*state)[3][2]; 270 | (*state)[3][2] = temp; 271 | 272 | // Rotate third row 3 columns to left 273 | temp = (*state)[0][3]; 274 | (*state)[0][3] = (*state)[3][3]; 275 | (*state)[3][3] = (*state)[2][3]; 276 | (*state)[2][3] = (*state)[1][3]; 277 | (*state)[1][3] = temp; 278 | } 279 | 280 | static uint8_t xtime(uint8_t x) 281 | { 282 | return ((x<<1) ^ (((x>>7) & 1) * 0x1b)); 283 | } 284 | 285 | // MixColumns function mixes the columns of the state matrix 286 | static void MixColumns(void) 287 | { 288 | uint8_t i; 289 | uint8_t Tmp,Tm,t; 290 | for(i = 0; i < 4; ++i) 291 | { 292 | t = (*state)[i][0]; 293 | Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3] ; 294 | Tm = (*state)[i][0] ^ (*state)[i][1] ; Tm = xtime(Tm); (*state)[i][0] ^= Tm ^ Tmp ; 295 | Tm = (*state)[i][1] ^ (*state)[i][2] ; Tm = xtime(Tm); (*state)[i][1] ^= Tm ^ Tmp ; 296 | Tm = (*state)[i][2] ^ (*state)[i][3] ; Tm = xtime(Tm); (*state)[i][2] ^= Tm ^ Tmp ; 297 | Tm = (*state)[i][3] ^ t ; Tm = xtime(Tm); (*state)[i][3] ^= Tm ^ Tmp ; 298 | } 299 | } 300 | 301 | // Multiply is used to multiply numbers in the field GF(2^8) 302 | #if MULTIPLY_AS_A_FUNCTION 303 | static uint8_t Multiply(uint8_t x, uint8_t y) 304 | { 305 | return (((y & 1) * x) ^ 306 | ((y>>1 & 1) * xtime(x)) ^ 307 | ((y>>2 & 1) * xtime(xtime(x))) ^ 308 | ((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ 309 | ((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))); 310 | } 311 | #else 312 | #define Multiply(x, y) \ 313 | ( ((y & 1) * x) ^ \ 314 | ((y>>1 & 1) * xtime(x)) ^ \ 315 | ((y>>2 & 1) * xtime(xtime(x))) ^ \ 316 | ((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ \ 317 | ((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))) \ 318 | 319 | #endif 320 | 321 | // MixColumns function mixes the columns of the state matrix. 322 | // The method used to multiply may be difficult to understand for the inexperienced. 323 | // Please use the references to gain more information. 324 | static void InvMixColumns(void) 325 | { 326 | int i; 327 | uint8_t a,b,c,d; 328 | for(i=0;i<4;++i) 329 | { 330 | a = (*state)[i][0]; 331 | b = (*state)[i][1]; 332 | c = (*state)[i][2]; 333 | d = (*state)[i][3]; 334 | 335 | (*state)[i][0] = Multiply(a, 0x0e) ^ Multiply(b, 0x0b) ^ Multiply(c, 0x0d) ^ Multiply(d, 0x09); 336 | (*state)[i][1] = Multiply(a, 0x09) ^ Multiply(b, 0x0e) ^ Multiply(c, 0x0b) ^ Multiply(d, 0x0d); 337 | (*state)[i][2] = Multiply(a, 0x0d) ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b); 338 | (*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e); 339 | } 340 | } 341 | 342 | 343 | // The SubBytes Function Substitutes the values in the 344 | // state matrix with values in an S-box. 345 | static void InvSubBytes(void) 346 | { 347 | uint8_t i,j; 348 | for(i=0;i<4;++i) 349 | { 350 | for(j=0;j<4;++j) 351 | { 352 | (*state)[j][i] = getSBoxInvert((*state)[j][i]); 353 | } 354 | } 355 | } 356 | 357 | static void InvShiftRows(void) 358 | { 359 | uint8_t temp; 360 | 361 | // Rotate first row 1 columns to right 362 | temp=(*state)[3][1]; 363 | (*state)[3][1]=(*state)[2][1]; 364 | (*state)[2][1]=(*state)[1][1]; 365 | (*state)[1][1]=(*state)[0][1]; 366 | (*state)[0][1]=temp; 367 | 368 | // Rotate second row 2 columns to right 369 | temp=(*state)[0][2]; 370 | (*state)[0][2]=(*state)[2][2]; 371 | (*state)[2][2]=temp; 372 | 373 | temp=(*state)[1][2]; 374 | (*state)[1][2]=(*state)[3][2]; 375 | (*state)[3][2]=temp; 376 | 377 | // Rotate third row 3 columns to right 378 | temp=(*state)[0][3]; 379 | (*state)[0][3]=(*state)[1][3]; 380 | (*state)[1][3]=(*state)[2][3]; 381 | (*state)[2][3]=(*state)[3][3]; 382 | (*state)[3][3]=temp; 383 | } 384 | 385 | 386 | // Cipher is the main function that encrypts the PlainText. 387 | static void Cipher(void) 388 | { 389 | uint8_t round = 0; 390 | 391 | // Add the First round key to the state before starting the rounds. 392 | AddRoundKey(0); 393 | 394 | // There will be Nr rounds. 395 | // The first Nr-1 rounds are identical. 396 | // These Nr-1 rounds are executed in the loop below. 397 | for(round = 1; round < Nr; ++round) 398 | { 399 | SubBytes(); 400 | ShiftRows(); 401 | MixColumns(); 402 | AddRoundKey(round); 403 | } 404 | 405 | // The last round is given below. 406 | // The MixColumns function is not here in the last round. 407 | SubBytes(); 408 | ShiftRows(); 409 | AddRoundKey(Nr); 410 | } 411 | 412 | static void InvCipher(void) 413 | { 414 | uint8_t round=0; 415 | 416 | // Add the First round key to the state before starting the rounds. 417 | AddRoundKey(Nr); 418 | 419 | // There will be Nr rounds. 420 | // The first Nr-1 rounds are identical. 421 | // These Nr-1 rounds are executed in the loop below. 422 | for(round=Nr-1;round>0;round--) 423 | { 424 | InvShiftRows(); 425 | InvSubBytes(); 426 | AddRoundKey(round); 427 | InvMixColumns(); 428 | } 429 | 430 | // The last round is given below. 431 | // The MixColumns function is not here in the last round. 432 | InvShiftRows(); 433 | InvSubBytes(); 434 | AddRoundKey(0); 435 | } 436 | 437 | static void BlockCopy(uint8_t* output, uint8_t* input) 438 | { 439 | uint8_t i; 440 | for (i=0;i 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "md5/md5.h" 15 | #include "h3c_AES_MD5/h3c_AES_MD5.h" 16 | 17 | #include "pcaphelper.h" 18 | #include 19 | #define sleep(x) Sleep(x) //x * 1000 20 | #define bool int 21 | #define false 0 22 | #define true 1 23 | 24 | #include "debug.h" 25 | 26 | // 自定义常量 27 | #define REQUEST 1 28 | #define RESPONSE 2 29 | #define SUCCESS 3 30 | #define FAILURE 4 31 | #define H3CDATA 10 32 | 33 | #define IDENTITY 1 34 | #define NOTIFICATION 2 35 | #define MD5 4 36 | #define AVAILABLE 20 37 | 38 | #define OID_802_3_PERMANENT_ADDRESS 0x01010101 39 | #define OID_802_3_CURRENT_ADDRESS 0x01010102 40 | 41 | typedef uint8_t EAP_ID; 42 | const uint8_t BroadcastAddr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; // 广播MAC地址 43 | const uint8_t MultcastAddr[6] = {0x01,0x80,0xc2,0x00,0x00,0x03}; // 多播MAC地址 44 | char H3C_VERSION[16]=""; // 华为客户端版本号 45 | //const char H3C_KEY[64] ="HuaWei3COM1X"; // H3C的固定密钥 46 | //const char H3C_KEY[64] ="Oly5D62FaE94W7"; // H3C的另一个固定密钥,网友取自MacOSX版本的iNode官方客户端 47 | char H3C_KEY[64] = ""; //H3C的固定密钥 48 | static char sprintbuffer[260]=""; 49 | uint8_t AES_MD5req[32]; 50 | uint8_t AES_MD5data[32]; 51 | uint8_t ip[4] = { 10, 0, 0, 0 }; // ip address template 52 | uint32_t random; // 4 random bytes 53 | 54 | // 子函数声明 55 | static void SendStartPkt(pcap_t *adhandle, const uint8_t mac[]); 56 | static void SendLogoffPkt(pcap_t *adhandle, const uint8_t mac[]); 57 | static void SendResponseIdentity(pcap_t *adhandle, 58 | const uint8_t request[], 59 | const uint8_t ethhdr[], 60 | const uint8_t ip[4], 61 | const char username[]); 62 | static void SendFirstResponseIdentity(pcap_t *adhandle, 63 | const uint8_t request[], 64 | const uint8_t ethhdr[], 65 | const uint8_t ip[4], 66 | const char username[]); 67 | static void SendResponseMD5(pcap_t *adhandle, 68 | const uint8_t request[], 69 | const uint8_t ethhdr[], 70 | const char username[], 71 | const char passwd[]); 72 | static void SendResponseAvailable(pcap_t *adhandle, 73 | const uint8_t request[], 74 | const uint8_t ethhdr[], 75 | const uint8_t ip[4], 76 | const char username[]); 77 | static void SendResponseNotification(pcap_t *handle, 78 | const uint8_t request[], 79 | const uint8_t ethhdr[]); 80 | static int GetMacFromDevice(uint8_t mac[6], const char *devicename); 81 | static void FillClientVersionArea(uint8_t area[]); 82 | static void FillWindowsVersionArea(uint8_t area[]); 83 | static void FillBase64Area(char area[]); 84 | static void FillMD5Area(uint8_t digest[], 85 | uint8_t id, 86 | const char passwd[], 87 | const uint8_t srcMD5[]); 88 | 89 | // From ip.c 90 | extern void GetIpFromDevice(uint8_t ip[4], const char DeviceName[]); 91 | 92 | // From main.c 93 | extern int stop_flag; 94 | extern void WriteLog(); 95 | 96 | /** 97 | * 函数:Authentication() 98 | * 99 | * 使用以太网进行802.1X认证(802.1X Authentication) 100 | * 该函数将上断循环,应答802.1X认证会话,直到遇到错误后才退出 101 | */ 102 | int Authentication(const char *UserName, const char *Password, const char *DeviceName, const char *Version, const char *H3C_key, int mode) 103 | { 104 | char errbuf[PCAP_ERRBUF_SIZE]; 105 | pcap_t *adhandle; // adapter handle 106 | uint8_t MAC[6]; 107 | char FilterStr[100]; 108 | FILE *fpinfo = NULL; 109 | struct bpf_program fcode; 110 | const int DefaultTimeout = 500; //设置接收超时参数,单位ms 111 | 112 | //重设版本号 113 | memset(H3C_VERSION, 0x00, 16); 114 | strcpy(H3C_VERSION, Version); 115 | sprintf(sprintbuffer, "当前版本号为:%s\n", H3C_VERSION); 116 | WriteLog(sprintbuffer); 117 | 118 | //重设H3C_KEY 119 | memset(H3C_KEY, 0x00, 64); 120 | strcpy(H3C_KEY, H3C_key); 121 | sprintf(sprintbuffer, "当前密钥号为:%s\n", H3C_KEY); 122 | WriteLog(sprintbuffer); 123 | 124 | /* 生成随机数 */ 125 | srand((unsigned)time(NULL)); 126 | random = ((uint32_t)rand() % 0xFFFF) * 0xFFFF + (uint32_t)rand(); // 注:可以选任意32位整数 127 | 128 | // NOTE: 这里没有检查网线是否已插好,网线插口可能接触上良 129 | /* 打开适配器(网卡) */ 130 | adhandle = pcap_open_live(DeviceName,65536,1,DefaultTimeout,errbuf); 131 | if (adhandle == NULL) { 132 | DPRINTF("%s", errbuf); 133 | WriteLog(errbuf); 134 | return 0;//exit(-1); 135 | } 136 | 137 | /* 查询本机MAC地址 */ 138 | GetMacFromDevice(MAC, DeviceName); 139 | printf("local %02x:%02x:%02x:%02x:%02x:%02x\n", MAC[0],MAC[1],MAC[2],MAC[3],MAC[4],MAC[5]); 140 | 141 | START_AUTHENTICATION: 142 | { 143 | /* 144 | * 设置过滤器: 145 | * 初始情况下只捕获发往本机的802.1X认证会话,上接收多播信息(避免误捕获其他客户端发出的多播信息) 146 | * 进入循环体前可以重设过滤器,那时再开始接收多播信息 147 | */ 148 | sprintf(FilterStr, "(ether proto 0x888e) and (ether dst host %02x:%02x:%02x:%02x:%02x:%02x)", 149 | MAC[0], MAC[1], MAC[2], MAC[3], MAC[4], MAC[5]); 150 | pcap_compile(adhandle, &fcode, FilterStr, 1, 0xff); 151 | pcap_setfilter(adhandle, &fcode); 152 | int retcode; 153 | struct pcap_pkthdr *header = NULL; 154 | const uint8_t *captured = NULL; 155 | bool serverIsFound; 156 | uint8_t ethhdr[14]={0}; // ethernet header 157 | bool neednewline = false; 158 | 159 | //// 使用本机MAC地址生成伪装IP地址。 160 | //ip[1] = MAC[2] ^ (uint8_t)rand(); 161 | //ip[2] = MAC[4] ^ (uint8_t)rand(); 162 | //ip[3] = MAC[5] ^ (uint8_t)rand(); 163 | 164 | // 主动发起认证会话 165 | SendStartPkt(adhandle, MAC); 166 | DPRINTF("[ ] Client: Start.\n"); 167 | WriteLog("Client: Start."); 168 | // 等待认证服务器的回应 169 | serverIsFound = false; 170 | neednewline = false; 171 | while (!serverIsFound) 172 | { 173 | if (stop_flag == 1) return 0; 174 | retcode = pcap_next_ex(adhandle, &header, &captured); 175 | if (retcode==1 && /*(EAP_Code)*/captured[18]==REQUEST) 176 | serverIsFound = true; 177 | else 178 | { 179 | neednewline = true; 180 | DPRINTF("."); 181 | sleep(1000); // 延时后重试 182 | SendStartPkt(adhandle, MAC); 183 | // NOTE: 这里没有检查网线是否接触上良或已被拔下 184 | } 185 | } 186 | if (neednewline) DPRINTF("\n"); 187 | 188 | // 填写应答包的报头(以后无须再修改) 189 | // 默认以单播方式应答802.1X认证设备发来的Request 190 | memcpy(ethhdr+0, captured+6, 6); 191 | memcpy(ethhdr+6, MAC, 6); 192 | ethhdr[12] = 0x88; 193 | ethhdr[13] = 0x8e; 194 | 195 | printf("host %02x:%02x:%02x:%02x:%02x:%02x\n", ethhdr[0], ethhdr[1], ethhdr[2], ethhdr[3], ethhdr[4], ethhdr[5]); 196 | 197 | // 分情况应答下一个包 198 | // 收到的第一个包可能是Request Notification。取决于校方网络配置 199 | switch (/*(EAP_Type)*/captured[22]) 200 | { 201 | case NOTIFICATION: 202 | DPRINTF("[%d] Server: Request Notification!\n", captured[19]); 203 | WriteLog("Server: Request Notification!"); 204 | // 发送Response Notification 205 | SendResponseNotification(adhandle, captured, ethhdr); 206 | DPRINTF(" Client: Response Notification.\n"); 207 | WriteLog("Client: Response Notification."); 208 | // 继续接收下一个Request包 209 | retcode = pcap_next_ex(adhandle, &header, &captured); 210 | assert(retcode==1); 211 | assert(/*(EAP_Code)*/captured[18] == REQUEST); 212 | break; 213 | case IDENTITY: 214 | // 通常情况会收到包Request Identity,应回答Fisrt Response Identity 215 | DPRINTF("[%d] Server: Request Identity!\n", captured[19]); 216 | WriteLog("Server: Request Identity!"); 217 | GetIpFromDevice(ip, DeviceName); 218 | // SendResponseIdentity(adhandle, captured, ethhdr, ip, UserName); 219 | SendFirstResponseIdentity(adhandle, captured, ethhdr, ip, UserName); //我校的第一个Response Identity与通常格式不同 220 | DPRINTF("[%d] Client: Response First Identity.\n", (EAP_ID)captured[19]); 221 | WriteLog("Client: Response 1st Identity."); 222 | break; 223 | case AVAILABLE: 224 | // 遇到AVAILABLE包时需要特殊处理 225 | // 中南财经政法大学目前使用的格式: 226 | // 收到第一个Request AVAILABLE时要回答Response Identity 227 | DPRINTF("[%d] Server: Request AVAILABLE!\n", captured[19]); 228 | WriteLog("Server: Request AVAILABLE!"); 229 | GetIpFromDevice(ip, DeviceName); 230 | SendResponseIdentity(adhandle, captured, ethhdr, ip, UserName); 231 | DPRINTF("[%d] Client: Response Identity.", (EAP_ID)captured[19]); 232 | WriteLog("Client: Response Identity."); 233 | break; 234 | case MD5: 235 | DPRINTF("[%d] Server: Request MD5-Challenge!\n", (EAP_ID)captured[19]); 236 | WriteLog("Server: MD5-Challenge!"); 237 | SendResponseMD5(adhandle, captured, ethhdr, UserName, Password); 238 | DPRINTF("[%d] Client: Response MD5-Challenge.\n", (EAP_ID)captured[19]); 239 | WriteLog("Client:Challenge Accepted."); 240 | break; 241 | default: 242 | DPRINTF("[%d] Server: Unknown Request!\n", captured[19]); 243 | WriteLog("Server: Unknown Request!"); 244 | } 245 | 246 | // 重设过滤器,只捕获华为802.1X认证设备发来的包(包括多播Request Identity / Request AVAILABLE) 247 | sprintf(FilterStr, "(ether proto 0x888e) and (ether src host %02x:%02x:%02x:%02x:%02x:%02x)", 248 | captured[6],captured[7],captured[8],captured[9],captured[10],captured[11]); 249 | pcap_compile(adhandle, &fcode, FilterStr, 1, 0xff); 250 | pcap_setfilter(adhandle, &fcode); 251 | 252 | // 进入循环体 253 | for (;;) 254 | { 255 | if (stop_flag == 1) return 0; 256 | neednewline = false; 257 | 258 | // 调用pcap_next_ex()函数捕获数据包 259 | while (pcap_next_ex(adhandle, &header, &captured) != 1) 260 | { 261 | if (stop_flag == 1) return 0; 262 | neednewline = true; 263 | DPRINTF("."); // 若捕获失败,则等1秒后重试 264 | sleep(1000); // 直到成功捕获到一个数据包后再跳出 265 | // NOTE: 这里没有检查网线是否已被拔下或插口接触上良 266 | } 267 | if (neednewline) DPRINTF("\n"); 268 | 269 | // 根据收到的Request,回应相应的Response包 270 | if (/*(EAP_Code)*/captured[18] == REQUEST) 271 | { 272 | switch (/*(EAP_Type)*/captured[22]) 273 | { 274 | case IDENTITY: 275 | if (mode == 2) 276 | { 277 | // painkiller 278 | DPRINTF("[%d] Server: Request Identity!\n", (EAP_ID)captured[19]); 279 | WriteLog("Server: Request Identity!"); 280 | DPRINTF("[%d] Client: Response Nothing.\n", (EAP_ID)captured[19]); 281 | WriteLog("Client: Response Nothing."); 282 | } 283 | else 284 | { 285 | DPRINTF("[%d] Server: Request Identity!\n", (EAP_ID)captured[19]); 286 | WriteLog("Server: Request Identity!"); 287 | GetIpFromDevice(ip, DeviceName); 288 | SendResponseIdentity(adhandle, captured, ethhdr, ip, UserName); 289 | DPRINTF("[%d] Client: Response Identity.\n", (EAP_ID)captured[19]); 290 | WriteLog("Client: Response Identity."); 291 | } 292 | break; 293 | case AVAILABLE: 294 | DPRINTF("[%d] Server: Request AVAILABLE!\n", (EAP_ID)captured[19]); 295 | WriteLog("Server: Request AVAILABLE!"); 296 | //GetIpFromDevice(ip, DeviceName); 297 | SendResponseAvailable(adhandle, captured, ethhdr, ip, UserName); 298 | DPRINTF("[%d] Client: Response AVAILABLE.\n", (EAP_ID)captured[19]); 299 | WriteLog("Client: Response AVAILABLE."); 300 | break; 301 | case MD5: 302 | DPRINTF("[%d] Server: Request MD5-Challenge!\n", (EAP_ID)captured[19]); 303 | WriteLog("Server: MD5-Challenge!"); 304 | SendResponseMD5(adhandle, captured, ethhdr, UserName, Password); 305 | DPRINTF("[%d] Client: Response MD5-Challenge.\n", (EAP_ID)captured[19]); 306 | WriteLog("Client:Challenge Accepted."); 307 | break; 308 | case NOTIFICATION: 309 | DPRINTF("[%d] Server: Request Notification!\n", captured[19]); 310 | SendResponseNotification(adhandle, captured, ethhdr); 311 | DPRINTF(" Client: Response Notification.\n"); 312 | break; 313 | default: 314 | DPRINTF("[%d] Server: Request (type:%d)!\n", (EAP_ID)captured[19], /*(EAP_Type)*/captured[22]); 315 | DPRINTF("Error! Unexpected request type\n"); 316 | return 0;//exit(-1); 317 | break; 318 | } 319 | } 320 | else if (/*(EAP_Code)*/captured[18] == FAILURE) 321 | { // 处理认证失败信息 322 | uint8_t errtype = captured[22]; 323 | uint8_t msgsize = captured[23]; 324 | DPRINTF("[%d] Server: Failure.\n", (EAP_ID)captured[19]); 325 | WriteLog("Server: Failure."); 326 | if (errtype==0x09 && msgsize>0) 327 | { // 输出错误提示消息 328 | memcpy(sprintbuffer, &captured[24], msgsize); 329 | sprintbuffer[msgsize] = '\n'; 330 | sprintbuffer[msgsize+1] = 0x00; 331 | DPRINTF("%s", sprintbuffer); 332 | WriteLog(sprintbuffer); 333 | // 已知的几种错误如下 334 | // E2531:用户已存在 335 | // E2535:Service is paused 336 | // E2542:该用户帐号已经在别处登录 337 | // E2547:接入时段限制 338 | // E2553:密码错误 339 | // E2602:认证会话上存在 340 | // E3137:客户端版本号无效 341 | } 342 | else if (errtype==0x08) 343 | { // 可能网络无流量时服务器结束此次802.1X认证会话 344 | // 遇此情况客户端立刻发起新的认证会话 345 | WriteLog("Server: Stop Connection 0x08."); 346 | goto START_AUTHENTICATION; 347 | } 348 | else 349 | { 350 | DPRINTF("errtype=0x%02x\n", errtype); 351 | sprintf(sprintbuffer, "errtype=0x%02x\n", errtype); 352 | WriteLog(sprintbuffer); 353 | } 354 | if (mode == 1 || mode == 2) 355 | { 356 | goto START_AUTHENTICATION; 357 | } 358 | else 359 | { 360 | return 0;//exit(-1); 361 | } 362 | } 363 | else if (/*(EAP_Code)*/captured[18] == SUCCESS) 364 | { 365 | DPRINTF("[%d] Server: Success.\n", captured[19]); 366 | //sprintf(sprintbuffer, "Server: Success.\n", captured[19]); 367 | WriteLog("Server: Success."); 368 | } 369 | else if (/*(EAP_Code)*/captured[18] == 0x0A) 370 | { 371 | if (captured[26] == 0x35) 372 | { 373 | for (int i = 0; i < 32; i++) 374 | { 375 | AES_MD5req[i] = captured[i + 27]; 376 | } 377 | h3c_AES_MD5_decryption(AES_MD5data, AES_MD5req); 378 | random = ((uint32_t)rand() % 0xFFFF) * 0xFFFF + (uint32_t)rand(); //触发重新生成随机KEY 379 | WriteLog("Server: (data 0x0a)\n"); 380 | } 381 | } 382 | else 383 | { 384 | DPRINTF("[%d] Server: (unknown data)\n", captured[19]); 385 | WriteLog("Server: (unknown data)"); 386 | } 387 | } 388 | } 389 | return (0); 390 | } 391 | 392 | 393 | 394 | static 395 | int GetMacFromDevice(uint8_t mac[6], const char *devicename) 396 | { 397 | #if defined(WIN32) 398 | LPADAPTER lpAdapter; 399 | PPACKET_OID_DATA OidData; 400 | BOOLEAN status; 401 | 402 | lpAdapter = PacketOpenAdapter((char *)devicename); 403 | 404 | if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE)) { 405 | return 0; 406 | } 407 | 408 | OidData = (PPACKET_OID_DATA)malloc(6 + sizeof(PACKET_OID_DATA)); 409 | if (OidData == NULL) { 410 | return 0; 411 | } 412 | 413 | OidData->Oid = OID_802_3_CURRENT_ADDRESS; 414 | OidData->Length = 6; 415 | ZeroMemory(OidData->Data, 6); 416 | 417 | status = PacketRequest(lpAdapter, FALSE, OidData); 418 | if (status == false) { 419 | return 0; 420 | } 421 | 422 | memcpy((void *)mac, (void *)OidData->Data, 6); 423 | 424 | free(OidData); 425 | PacketCloseAdapter(lpAdapter); 426 | 427 | return 0; 428 | #else 429 | int fd; 430 | int err; 431 | struct ifreq ifr; 432 | 433 | fd = socket(PF_PACKET, SOCK_RAW, htons(0x0806)); 434 | assert(fd != -1); 435 | 436 | assert(strlen(devicename) < IFNAMSIZ); 437 | strncpy(ifr.ifr_name, devicename, IFNAMSIZ); 438 | ifr.ifr_addr.sa_family = AF_INET; 439 | 440 | err = ioctl(fd, SIOCGIFHWADDR, &ifr); 441 | assert(err != -1); 442 | memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); 443 | 444 | err = close(fd); 445 | assert(err != -1); 446 | return 0; 447 | #endif 448 | } 449 | 450 | static 451 | void SendStartPkt(pcap_t *handle, const uint8_t localmac[]) 452 | { 453 | uint8_t packet[18]; 454 | 455 | // Ethernet Header (14 Bytes) 456 | memcpy(packet, BroadcastAddr, 6); 457 | memcpy(packet+6, localmac, 6); 458 | packet[12] = 0x88; 459 | packet[13] = 0x8e; 460 | 461 | // EAPOL (4 Bytes) 462 | packet[14] = 0x01; // Version=1 463 | packet[15] = 0x01; // Type=Start 464 | packet[16] = packet[17] =0x00;// Length=0x0000 465 | 466 | // delete(为了兼容上同院校的网络配置,这里发送两遍Start包) 467 | // 只发一次广播包! 468 | // 1、广播发送Strat包 469 | //pcap_sendpacket(handle, packet, sizeof(packet)); 470 | // 2、多播发送Strat包 471 | memcpy(packet, MultcastAddr, 6); 472 | pcap_sendpacket(handle, packet, sizeof(packet)); 473 | } 474 | 475 | static 476 | void SendResponseAvailable(pcap_t *handle, const uint8_t request[], const uint8_t ethhdr[], const uint8_t ip[4], const char username[]) 477 | { 478 | int i; 479 | uint16_t eaplen; 480 | int usernamelen; 481 | uint8_t response[128]; 482 | 483 | assert(/*(EAP_Code)*/request[18] == REQUEST); 484 | assert(/*(EAP_Type)*/request[22] == AVAILABLE); 485 | 486 | // Fill Ethernet header 487 | memcpy(response, ethhdr, 14); 488 | 489 | // 802,1X Authentication 490 | // { 491 | response[14] = 0x1; // 802.1X Version 1 492 | response[15] = 0x0; // Type=0 (EAP Packet) 493 | //response[16~17]留空 // Length 494 | 495 | // Extensible Authentication Protocol 496 | // { 497 | response[18] = /*(EAP_Code)*/ RESPONSE; // Code 498 | response[19] = request[19]; // ID 499 | //response[20~21]留空 // Length 500 | response[22] = /*(EAP_Type)*/ AVAILABLE; // Type 501 | // Type-Data 502 | // { 503 | i = 23; 504 | response[i++] = 0x00;// 上报是否使用代理 505 | response[i++] = 0x15; // 上传IP地址 506 | response[i++] = 0x04; // 507 | memcpy(response+i, ip, 4);// 508 | i += 4; // 509 | response[i++] = 0x06; // 携带版本号 510 | response[i++] = 0x07; // 511 | FillBase64Area((char*)response+i);// 512 | i += 28; // 513 | response[i++] = ' '; // 两个空格符 514 | response[i++] = ' '; // 515 | usernamelen = strlen(username); 516 | memcpy(response+i, username, usernamelen);// 517 | i += usernamelen; // 518 | // } 519 | // } 520 | // } 521 | 522 | // 补填前面留空的两处Length 523 | eaplen = htons(i-18); 524 | memcpy(response+16, &eaplen, sizeof(eaplen)); 525 | memcpy(response+20, &eaplen, sizeof(eaplen)); 526 | 527 | // 发送 528 | pcap_sendpacket(handle, response, i); 529 | } 530 | 531 | 532 | static 533 | void SendResponseIdentity(pcap_t *adhandle, const uint8_t request[], const uint8_t ethhdr[], const uint8_t ip[4], const char username[]) 534 | { 535 | uint8_t response[128]; 536 | size_t i; 537 | uint16_t eaplen; 538 | int usernamelen; 539 | 540 | assert(/*(EAP_Code)*/request[18] == REQUEST); 541 | assert(/*(EAP_Type)*/request[22] == IDENTITY 542 | ||/*(EAP_Type)*/request[22] == AVAILABLE); // 兼容中南财经政法大学情况 543 | 544 | // Fill Ethernet header 545 | memcpy(response, ethhdr, 14); 546 | 547 | // 802,1X Authentication 548 | // { 549 | response[14] = 0x1; // 802.1X Version 1 550 | response[15] = 0x0; // Type=0 (EAP Packet) 551 | //response[16~17]留空 // Length 552 | 553 | // Extensible Authentication Protocol 554 | // { 555 | response[18] = /*(EAP_Code)*/ RESPONSE; // Code 556 | response[19] = request[19]; // ID 557 | //response[20~21]留空 // Length 558 | response[22] = /*(EAP_Type)*/ IDENTITY; // Type 559 | response[23] = 0x16; 560 | response[24] = 0x20; 561 | memcpy(response + 25, AES_MD5data, 32); // AES_MD5 data 562 | // Type-Data 563 | // { 564 | i = 57; 565 | response[i++] = 0x15; // 上传IP地址 566 | response[i++] = 0x04; // 567 | memcpy(response+i, ip, 4);// 568 | i += 4; // 569 | response[i++] = 0x06; // 携带版本号 570 | response[i++] = 0x07; // 571 | FillBase64Area((char*)response+i);// 572 | i += 28; // 573 | response[i++] = ' '; // 两个空格符 574 | response[i++] = ' '; // 575 | usernamelen = strlen(username); //末尾添加用户名 576 | memcpy(response+i, username, usernamelen); 577 | i += usernamelen; 578 | assert(i <= sizeof(response)); 579 | // } 580 | // } 581 | // } 582 | 583 | // 补填前面留空的两处Length 584 | eaplen = htons(i-18); 585 | memcpy(response+16, &eaplen, sizeof(eaplen)); 586 | memcpy(response+20, &eaplen, sizeof(eaplen)); 587 | 588 | // 发送 589 | pcap_sendpacket(adhandle, response, i); 590 | return ; 591 | } 592 | 593 | void SendFirstResponseIdentity(pcap_t *adhandle, const uint8_t request[], const uint8_t ethhdr[], const uint8_t ip[4], const char username[]) 594 | { 595 | uint8_t response[128]; 596 | size_t i; 597 | uint16_t eaplen; 598 | int usernamelen; 599 | 600 | assert(/*(EAP_Code)*/request[18] == REQUEST); 601 | assert(/*(EAP_Type)*/request[22] == IDENTITY 602 | ||/*(EAP_Type)*/request[22] == AVAILABLE); // 兼容中南财经政法大学情况 603 | 604 | // Fill Ethernet header 605 | memcpy(response, ethhdr, 14); 606 | 607 | // 802,1X Authentication 608 | // { 609 | response[14] = 0x1; // 802.1X Version 1 610 | response[15] = 0x0; // Type=0 (EAP Packet) 611 | //response[16~17]留空 // Length 612 | 613 | // Extensible Authentication Protocol 614 | // { 615 | response[18] = /*(EAP_Code)*/ RESPONSE; // Code 616 | response[19] = request[19]; // ID 617 | //response[20~21]留空 // Length 618 | response[22] = /*(EAP_Type)*/ IDENTITY; // Type 619 | // Type-Data 620 | // { 621 | i = 23; 622 | //response[i++] = 0x15; // 上传IP地址 623 | //response[i++] = 0x04; // 624 | //memcpy(response+i, ip, 4);// 625 | //i += 4; 626 | //response[i++] = 10; 627 | //response[i++] = 106; 628 | //response[i++] = 83; 629 | //response[i++] = 117; 630 | // 631 | response[i++] = 0x06; // 携带版本号 632 | response[i++] = 0x07; // 633 | FillBase64Area((char*)response+i);// 634 | i += 28; // 635 | response[i++] = ' '; // 两个空格符 636 | response[i++] = ' '; // 637 | usernamelen = strlen(username); //末尾添加用户名 638 | memcpy(response+i, username, usernamelen); 639 | i += usernamelen; 640 | assert(i <= sizeof(response)); 641 | // } 642 | // } 643 | // } 644 | 645 | // 补填前面留空的两处Length 646 | eaplen = htons(i-18); 647 | memcpy(response+16, &eaplen, sizeof(eaplen)); 648 | memcpy(response+20, &eaplen, sizeof(eaplen)); 649 | 650 | // 发送 651 | pcap_sendpacket(adhandle, response, i); 652 | return; 653 | } 654 | 655 | 656 | static 657 | void SendResponseMD5(pcap_t *handle, const uint8_t request[], const uint8_t ethhdr[], const char username[], const char passwd[]) 658 | { 659 | uint16_t eaplen; 660 | size_t usernamelen; 661 | size_t packetlen; 662 | uint8_t response[128]; 663 | 664 | assert(/*(EAP_Code)*/request[18] == REQUEST); 665 | assert(/*(EAP_Type)*/request[22] == MD5); 666 | 667 | usernamelen = strlen(username); 668 | eaplen = htons(22+usernamelen); 669 | packetlen = 14+4+22+usernamelen; // ethhdr+EAPOL+EAP+usernamelen 670 | 671 | // Fill Ethernet header 672 | memcpy(response, ethhdr, 14); 673 | 674 | // 802,1X Authentication 675 | // { 676 | response[14] = 0x1; // 802.1X Version 1 677 | response[15] = 0x0; // Type=0 (EAP Packet) 678 | memcpy(response+16, &eaplen, sizeof(eaplen)); // Length 679 | 680 | // Extensible Authentication Protocol 681 | // { 682 | response[18] = /*(EAP_Code)*/ RESPONSE;// Code 683 | response[19] = request[19]; // ID 684 | response[20] = response[16]; // Length 685 | response[21] = response[17]; // 686 | response[22] = /*(EAP_Type)*/ MD5; // Type 687 | response[23] = 16; // Value-Size: 16 Bytes 688 | FillMD5Area(response+24, request[19], passwd, request+24); 689 | memcpy(response+40, username, usernamelen); 690 | // } 691 | // } 692 | 693 | pcap_sendpacket(handle, response, packetlen); 694 | } 695 | 696 | 697 | static 698 | void SendLogoffPkt(pcap_t *handle, const uint8_t localmac[]) 699 | { 700 | uint8_t packet[18]; 701 | 702 | // Ethernet Header (14 Bytes) 703 | memcpy(packet, MultcastAddr, 6); 704 | memcpy(packet+6, localmac, 6); 705 | packet[12] = 0x88; 706 | packet[13] = 0x8e; 707 | 708 | // EAPOL (4 Bytes) 709 | packet[14] = 0x01; // Version=1 710 | packet[15] = 0x02; // Type=Logoff 711 | packet[16] = packet[17] =0x00;// Length=0x0000 712 | 713 | // 发包 714 | pcap_sendpacket(handle, packet, sizeof(packet)); 715 | } 716 | 717 | 718 | // 函数: XOR(data[], datalen, key[], keylen) 719 | // 720 | // 使用密钥key[]对数据data[]进行异或加密 721 | //(注:该函数也可反向用于解密) 722 | static 723 | void XOR(uint8_t data[], unsigned dlen, const char key[], unsigned klen) 724 | { 725 | unsigned int i,j; 726 | 727 | // 先按正序处理一遍 728 | for (i=0; i>2 ]; 835 | area[j++] = Tbl[((c1&0x03)<<4)|((c2&0xf0)>>4) ]; 836 | area[j++] = Tbl[ ((c2&0x0f)<<2)|((c3&0xc0)>>6)]; 837 | area[j++] = Tbl[ c3&0x3f ]; 838 | } 839 | c1 = version[i++]; 840 | c2 = version[i++]; 841 | area[24] = Tbl[ (c1&0xfc)>>2 ]; 842 | area[25] = Tbl[((c1&0x03)<<4)|((c2&0xf0)>>4)]; 843 | area[26] = Tbl[ ((c2&0x0f)<<2)]; 844 | area[27] = '='; 845 | } 846 | 847 | //调用openssl提供的MD5函数 848 | //from md5.c 849 | extern void MD5Calc(unsigned char *data, unsigned int len, unsigned char *output); 850 | 851 | static void FillMD5Area(uint8_t digest[], uint8_t id, const char passwd[], const uint8_t srcMD5[]) 852 | { 853 | uint8_t msgbuf[128]; // msgbuf = ‘id‘ + ‘passwd’ + ‘srcMD5’ 854 | 855 | int passlen = strlen(passwd); 856 | int msglen = 1 + passlen + 16; 857 | assert(sizeof(msgbuf) >= msglen); 858 | 859 | msgbuf[0] = id; 860 | memcpy(msgbuf + 1, passwd, passlen); 861 | memcpy(msgbuf + 1 + passlen, srcMD5, 16); 862 | 863 | MD5Calc(msgbuf, msglen, digest); 864 | } -------------------------------------------------------------------------------- /License/gpl-3.0.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------