Bugün sizlere aslında kendim için yapmış olduğum bir proxy checkeri + source kodunu paylaşacağım. Bunu yaparken multithread ile ilgili gerekli bilgilerin internette eksik olduğunu gördüm ve belki sizin de işinize yarar diye sourcesini paylaşacağım.
source:
Beyler source indirme linki: proxy
Bu da programın indirme linki: proxy
Edit: Beyler bu da virustotal linki https://www.virustotal.com/#/file/57dd83657016817b03a26da5f8861835dc2495608b843b02d65b95ffba0ae2c1/detection
Hayatında ismini bile duymadığım virüs programı 13.5 kb lık programa virüslü demiş.
source:
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Threading;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Form1.CheckForIllegalCrossThreadCalls = false;
}
public static int counter = 0;
Thread[] threads = new Thread[1];
SemaphoreSlim semaphore = new SemaphoreSlim(initialCount: 1);
private **** button3_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 0)
{
SaveFileDialog fs = new SaveFileDialog();
fs.RestoreDirectory = true;
fs.Filter = "txt files (*.txt)|*.txt";
fs.FilterIndex = 1;
fs.ShowDialog();
if (!(fs.FileName == null))
{
using (StreamWriter sw = new StreamWriter(fs.FileName))
{
foreach (string line in listBox1.Items)
{
if (line.StartsWith("Working Proxy: "))
{
sw.WriteLine(line);
}
}
}
}
}
}
public **** thread1(string proxy, int gelen,string site)
{
try
{
semaphore.Wait();
WebClient web = new WebClient();
web.Proxy = new WebProxy(proxy);
if (web.DownloadString(site) != "")
{
listBox1.Items.Add("Working Proxy: " + proxy);
}
else
{
listBox1.Items.Add("Unresponsive Proxy: " + proxy);
}
}
catch (Exception)
{
listBox1.Items.Add("Unresponsive Proxy: " + proxy);
}
semaphore.Release();
return;
}
private **** button1_Click_1(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox1.Text == null)
{
MessageBox.Show("Bir website linki girin.");
}
else
{
threads = new Thread[trackBar1.Value];
semaphore = new SemaphoreSlim(initialCount: trackBar1.Value);
string textim = textBox1.Text;
textBox1.Enabled = false;
button1.Enabled = false;
trackBar1.Enabled = false;
OpenFileDialog fo = new OpenFileDialog();
fo.RestoreDirectory = true;
fo.Multiselect = false;
fo.Filter = "txt files (*.txt)|*.txt";
fo.FilterIndex = 1;
fo.ShowDialog();
if (fo.FileName != null)
{
List<string> proxies = new List<string>();
using (StreamReader sr = new StreamReader(fo.FileName))
{
while (sr.Peek() != -1)
{
string proxyPattern = @"\d{1,3}(\.\d{1,3}){3}:\d{1,5}";
Match match = Regex.Match(sr.ReadLine(), proxyPattern);
if (match.Success)
{
proxies.Add(match.Groups[0].Value);
++counter;
}
}
}
foreach (string proxy in proxies)
{
--counter;
Thread th = new Thread(new ThreadStart(() => thread1(proxy, counter, textim)));
th.Start();
//new Thread(thread1).Start(proxy,counter);
/*
th.Start();
if (counter<=0)
{
//Thread.Sleep(5000);
th.Abort();
th.Interrupt();
MessageBox.Show("Bitti!");
}*/
}
}
}
}
private **** button2_Click(object sender, EventArgs e)
{
MessageBox.Show(Convert.ToString(trackBar1.Value));
}
private **** timer1_Tick(object sender, EventArgs e)
{
label2.Text = Convert.ToString(trackBar1.Value);
}
private **** Form1_Load(object sender, EventArgs e)
{
timer1.Start();
}
}
}
Beyler source indirme linki: proxy
Bu da programın indirme linki: proxy
Edit: Beyler bu da virustotal linki https://www.virustotal.com/#/file/57dd83657016817b03a26da5f8861835dc2495608b843b02d65b95ffba0ae2c1/detection
Hayatında ismini bile duymadığım virüs programı 13.5 kb lık programa virüslü demiş.
Son düzenleme:
