shadowsocks与ishadowsocks的结合
[shadowsocks]1是现在翻墙界的一款优秀软件。
http://www.ishadowsocks.com/#free是一个对外免费提供ss账号的网站,它每6小时会更换一次密码。
对于开发人员来说,使用非常简单,但是对于小白用户来说,可能还是有一定的困难。由于shadowsocks是一款开源软件,所以我们可以修改shadowsocks源码,让它自动从ishadowsocks抓取密码。
1、观察:打开shadowsocks,添加服务器进去,发现生成了gui-config.json这个文件,里面记录有服务器账号密码等,实例如下:
{
"configs" : [
{
"server" : "US1.ISS.TF",
"server_port" : 8989,
"password" : "29558245",
"method" : "aes-256-cfb",
"remarks" : ""}
,
{
"server" : "HK2.ISS.TF",
"server_port" : 8989,
"password" : "11527854",
"method" : "aes-256-cfb",
"remarks" : ""}
,
{
"server" : "HK3.ISS.TF",
"server_port" : 8989,
"password" : "99763157",
"method" : "aes-256-cfb",
"remarks" : ""}
],
"strategy" : null,
"index" : 0,
"global" : false,
"enabled" : false,
"shareOverLan" : false,
"isDefault" : false,
"localPort" : 1080,
"pacUrl" : null,
"useOnlinePac" : false,
"availabilityStatistics" : false}
2、思路:我们用php等语言写个抓取密码并生成gui-config.json的脚本放服务器上,修改shadowsocks源码,让shadowsocks启动的时候从我们指定的网址获取gui-config.json文件。
3、行动
修改后的shadowsocks源码
using Shadowsocks.Controller;
using Shadowsocks.Properties;
using Shadowsocks.View;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace Shadowsocks
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Util.Utils.ReleaseMemory(true);
using (Mutex mutex = new Mutex(false, "Global\\Shadowsocks_" + Application.StartupPath.GetHashCode()))
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!mutex.WaitOne(0, false))
{
Process[] oldProcesses = Process.GetProcessesByName("Shadowsocks");
if (oldProcesses.Length > 0)
{
Process oldProcess = oldProcesses[0];
}
MessageBox.Show(I18N.GetString("Find Shadowsocks icon in your notify tray.") + "\n" +
I18N.GetString("If you want to start multiple Shadowsocks, make a copy in another directory."),
I18N.GetString("Shadowsocks is already running."));
return;
}
Directory.SetCurrentDirectory(Application.StartupPath);
#if !DEBUG
Logging.OpenLogFile();
#endif
if (File.Exists("gui-config.json"))
{
File.Delete("gui-config.json");
}
try
{
new System.Net.WebClient().DownloadFile("https://xxxx/", "gui-config.json");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"下载数据异常");
}
if (!File.Exists("pac.txt"))
{
try
{
new System.Net.WebClient().DownloadFile("https://xxxx/pac.txt", "pac.txt");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "下载pac异常");
}
}
ShadowsocksController controller = new ShadowsocksController();
MenuViewController viewController = new MenuViewController(controller);
controller.Start();
Application.Run();
}
}
}
}
xxxx/index.php
<?php
$subject = file_get_contents("http://www.ishadowsocks.com/");
preg_match('/<h4>A密码:(.*)<\/h4>/',$subject,$APassword);
preg_match('/<h4>B密码:(.*)<\/h4>/',$subject,$BPassword);
preg_match('/<h4>C密码:(.*)<\/h4>/',$subject,$CPassword);
$config = '{
"configs" : [
{
"server" : "US1.ISS.TF",
"server_port" : 8989,
"password" : "' . $APassword[1] . '",
"method" : "aes-256-cfb",
"remarks" : ""}
,
{
"server" : "HK2.ISS.TF",
"server_port" : 8989,
"password" : "' . $BPassword[1] . '",
"method" : "aes-256-cfb",
"remarks" : ""}
,
{
"server" : "HK3.ISS.TF",
"server_port" : 8989,
"password" : "' . $CPassword[1] . '",
"method" : "aes-256-cfb",
"remarks" : ""}
],
"strategy" : null,
"index" : 0,
"global" : false,
"enabled" : false,
"shareOverLan" : false,
"isDefault" : false,
"localPort" : 1080,
"pacUrl" : null,
"useOnlinePac" : false,
"availabilityStatistics" : false}
';
echo $config;
注:使用的shadowsocks源码版本为2.5.6,之后的版本不是作者本人发的,不建议使用
2015年10月3日21:12:52
附件
http://www.400gb.com/file/121884002
解压密码:blog.lanyus.com
你好~请问修改SS的源码是那个文件?最近新接触SS还不太明白,还有,源码版本的SS是用什么语言环境打开的?c++编译器吗?
@yuski使用的编译器是vs2015社区版,修改的文件是Program.cs,语言是C#
如何改成每隔几分钟重新下载一次呢
@sciencesoft,改了也得重启软件才行,意义不大
@ilanyu 那就干脆设置为自动重启软件呢?
有没有php源码的