【发布时间】:2019-06-25 18:52:09
【问题描述】:
我可能写的不对(我是 C# 新手,哈哈),但我需要 C# 白名单/激活/许可方面的帮助。
因此,如果我在文本框中将 1111-1111-1111-1111 写为许可证密钥,我会得到 31-12-9999 作为到期日,而不是 Discord#5550 作为用户名,这是预期的,但不适用于多行。
我还需要密钥旁边的到期日期和用户名,我正在尝试拆分字符串,但它一次只能用于一行,所以即使我使用 2222-2222-2222-2222 作为密钥,它仍然会得到 Not Discord#5550 作为用户名,这不应该发生,应该是 charlootus#3330.
我已将代码留给你们查看和修复。
白名单(也叫pastebin,看代码):
1111-1111-1111-1111|31-12-9999|Not Discord#5550
2222-2222-2222-2222|31-12-9999|charlootus#3330
简化:
程序不知道到期日或用户名,它从从 Pastebin 下载的字符串中获取它,并使用输入的密钥搜索相邻的用户名和到期日,然后验证。第二个关键是从第一行提取到期和用户名,这是不应该发生的。
应该很容易解决,但我环顾四周,似乎找不到任何东西。
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace loader
{
// Token: 0x02000002 RID: 2
public partial class entry : Form
{
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
public entry()
{
this.InitializeComponent();
}
// Token: 0x06000002 RID: 2 RVA: 0x00002234 File Offset: 0x00000434
private async void button1_Click(object sender, EventArgs e)
{
if (this.textBox1.Text.Length != 19)
{
string caption = "License key is not valid.";
string text = "License key is not valid." + Environment.NewLine + Environment.NewLine + "Make sure you enter it in AAAA-BBBB-CCCC-DDDD format.";
MessageBoxButtons buttons = MessageBoxButtons.OK;
if (MessageBox.Show(this, text, caption, buttons, MessageBoxIcon.Hand) == DialogResult.OK)
{
this.button1.Text = "Submit key";
this.button1.Enabled = true;
}
}
else
{
this.textBox1.Enabled = false;
this.textBox1.Text = this.textBox1.Text.ToUpper();
this.button1.Enabled = false;
string[] array = new string[]
{
"Verifying key.",
"Verifying key..",
"Verifying key...",
};
foreach (string text2 in array)
{
this.button1.Text = text2;
await Task.Delay(new Random().Next(450, 850));
}
string[] array2 = null;
string whitelist = new System.Net.WebClient() { Proxy = null }.DownloadString("https://pastebin.com/raw/ai8q5GEA");
string fin = String.Format(this.textBox1.Text);
string[] result = whitelist.Split('|');
string whitelistx = result[0];
string expiry = result[1];
string username = result[2];
if (whitelist.Contains(fin))
{
var date = DateTime.ParseExact(expiry, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
var result1 = (date - DateTime.Now.Date).Days;
if (result1 >= 0)
{
string caption2 = "Success!";
if (MessageBox.Show(this, string.Concat(new string[]
{
"License key is valid.",
Environment.NewLine,
Environment.NewLine,
"Hi ", username, "! Key expires on the ", expiry,
Environment.NewLine,
"Restart DeluxeUnban."
}), caption2, MessageBoxButtons.OK, MessageBoxIcon.Asterisk) == DialogResult.OK)
{
this.button1.Text = "Verify license";
this.button1.Enabled = true;
this.textBox1.Enabled = true;
System.IO.File.WriteAllText(@"C:\NVIDIA\username.txt", username);
System.IO.File.WriteAllText(@"C:\NVIDIA\expiry.txt", expiry);
System.IO.File.WriteAllText(@"C:\NVIDIA\license.txt", this.textBox1.Text);
}
Application.Exit();
}
else
{
string caption3 = "License key is not valid";
if (MessageBox.Show(this, "License key has expired.", caption3, MessageBoxButtons.OK, MessageBoxIcon.Hand) == DialogResult.OK)
{
this.button1.Text = "Verify license";
this.button1.Enabled = true;
this.textBox1.Enabled = true;
}
}
}
else
{
string caption3 = "License key is not valid";
if (MessageBox.Show(this, "License key is incorrect." + Environment.NewLine + Environment.NewLine + "Make sure you didn't enter O instead of 0 (zero) or 1 instead of l (small L)", caption3, MessageBoxButtons.OK, MessageBoxIcon.Hand) == DialogResult.OK)
{
this.button1.Text = "Verify license";
this.button1.Enabled = true;
this.textBox1.Enabled = true;
}
}
}
}
// Token: 0x06000003 RID: 3 RVA: 0x0000205E File Offset: 0x0000025E
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("link hidden");
}
}
}
【问题讨论】:
-
你调试代码了吗?您在
whitelist中获得了什么价值? -
你读过你的代码吗?您总是显示第一个到期日期和用户名
-
是的,我做到了i.imgur.com/jwvqCWI.png
-
请不要破坏您的帖子。通过在 Stack Exchange 网络上发布,您已授予 SE 分发该内容的不可撤销的权利(在 CC BY-SA 3.0 license 下)。根据 SE 政策,任何破坏行为都将被撤销。