Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jul 17, 2014
1 parent 13264d2 commit 08453eb
Show file tree
Hide file tree
Showing 135 changed files with 17,225 additions and 0 deletions.
Binary file added bin/linux/hardseed
Binary file not shown.
Binary file added bin/windows/cygasn1-8.dll
Binary file not shown.
Binary file added bin/windows/cygcom_err-2.dll
Binary file not shown.
Binary file added bin/windows/cygcrypt-0.dll
Binary file not shown.
Binary file added bin/windows/cygcrypto-1.0.0.dll
Binary file not shown.
Binary file added bin/windows/cygcurl-4.dll
Binary file not shown.
Binary file added bin/windows/cyggcc_s-1.dll
Binary file not shown.
Binary file added bin/windows/cyggssapi-3.dll
Binary file not shown.
Binary file added bin/windows/cygheimbase-1.dll
Binary file not shown.
Binary file added bin/windows/cygheimntlm-0.dll
Binary file not shown.
Binary file added bin/windows/cyghx509-5.dll
Binary file not shown.
Binary file added bin/windows/cygiconv-2.dll
Binary file not shown.
Binary file added bin/windows/cygidn-11.dll
Binary file not shown.
Binary file added bin/windows/cygintl-8.dll
Binary file not shown.
Binary file added bin/windows/cygkrb5-26.dll
Binary file not shown.
Binary file added bin/windows/cyglber-2-4-2.dll
Binary file not shown.
Binary file added bin/windows/cygldap-2-4-2.dll
Binary file not shown.
Binary file added bin/windows/cygroken-18.dll
Binary file not shown.
Binary file added bin/windows/cygsasl2-3.dll
Binary file not shown.
Binary file added bin/windows/cygsqlite3-0.dll
Binary file not shown.
Binary file added bin/windows/cygssh2-1.dll
Binary file not shown.
Binary file added bin/windows/cygssl-1.0.0.dll
Binary file not shown.
Binary file added bin/windows/cygstdc++-6.dll
Binary file not shown.
Binary file added bin/windows/cygwin1.dll
Binary file not shown.
Binary file added bin/windows/cygwind-0.dll
Binary file not shown.
Binary file added bin/windows/cygz.dll
Binary file not shown.
Binary file added bin/windows/hardseed.exe
Binary file not shown.
42 changes: 42 additions & 0 deletions build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
PROJECT(main)


SET(SRC_LIST ../src/main.cpp
../src/lib/self/Webpage.cpp
../src/lib/self/TopicsListWebpage.cpp ../src/lib/self/AichengTopicsListWebpage.cpp ../src/lib/self/CaoliuTopicsListWebpage.cpp
../src/lib/self/TopicWebpage.cpp ../src/lib/self/AichengTopicWebpage.cpp ../src/lib/self/CaoliuTopicWebpage.cpp
../src/lib/self/SeedWebpage.cpp ../src/lib/self/JandownSeedWebpage.cpp ../src/lib/self/RmdownSeedWebpage.cpp
../src/lib/self/Aicheng.cpp ../src/lib/self/Caoliu.cpp
../src/lib/helper/Time.cpp ../src/lib/helper/CmdlineOption.cpp ../src/lib/helper/Misc.cpp)
SET(CMAKE_EXE_LINKER_FLAGS "-lcurl -lpthread")

# linux
#>>>>>>>>>>>>>>>>>>>>>>

## debug
#SET(CMAKE_CXX_COMPILER "clang++")
#SET(CMAKE_CXX_FLAGS "-std=c++11 -Werror -Weverything -Wno-documentation -Wno-disabled-macro-expansion -Wno-float-equal -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-global-constructors -Wno-exit-time-destructors -Wno-missing-prototypes -Wno-padded")
#SET(CMAKE_BUILD_TYPE debug)
#ADD_EXECUTABLE(main ${SRC_LIST})

# release
SET(CMAKE_CXX_COMPILER "g++")
SET(CMAKE_CXX_FLAGS "-std=c++11 -O3")
SET(CMAKE_BUILD_TYPE release)
ADD_EXECUTABLE(hardseed ${SRC_LIST})
INSTALL(PROGRAMS hardseed DESTINATION /usr/bin/)

#<<<<<<<<<<<<<<<<<<<<<<


## cygwin
##>>>>>>>>>>>>>>>>>>>>>>

#SET(CMAKE_CXX_COMPILER "clang++")
#SET(CMAKE_CXX_FLAGS "-std=c++11 -O3 -s -DCYGWIN")
#SET(CMAKE_BUILD_TYPE release)
#ADD_EXECUTABLE(hardseed ${SRC_LIST})
#target_link_libraries(hardseed /bin/cygcurl-4.dll)
#target_link_libraries(hardseed /lib/libiconv.a)

##<<<<<<<<<<<<<<<<<<<<<<
91 changes: 91 additions & 0 deletions doc/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
hardseed is a batch seeds and pictures download utiltiy from CaoLiu and AiCheng forum. It's easy and simple to use. Usually, you could issue it as follow:
$ hardseed
or
$ hardseed --saveas-path ~/downloads --multi-threads 4 --topics-range 8 64 --av-class Aicheng_west --timeout-download-picture 32 --hate X-Art --proxy http://127.0.0.1:8087

--help
Show this help infomation what you are seeing.

--version
Show current version.

--av-class
There are twelve av classes: caoliu_west_reposted, caoliu_cartoon_reposted, caoliu_asia_mosaicked_reposted, caoliu_asia_non_mosaicked_reposted, caoliu_west_original, caoliu_cartoon_original, caoliu_asia_mosaicked_original, caoliu_asia_non_mosaicked_original, aicheng_west, aicheng_cartoon, aicheng_asia_mosaicked and aicheng_asia_non_mosaicked.
As the name implies, "caoliu" stands for CaoLiu forum, "aicheng" for AiCheng forum, "reposted" and "original" is clearity, you konw which one is your best lover (yes, only one).
The default is aicheng_asia_mosaicked.

--concurrent-tasks
You can set more than one proxy, each proxy could more than one concurrent tasks. This option set the number of concurrent tasks of each prox.
The max and default number is 16.

--timeout-download-picture
Some pictures too big to download in few seconds. So, you should set the download picture timeout seconds.
The default timeout is 32 seconds.

--topics-range
Set the range of to download topics. E.G.:
--topics-range 2 16
--topics-range 8 (I.E., --topics-range 1 8)
--topics-range -1 (I.E., all topics of this av class)
The default topics range is 128

--saveas-path
Set the path to save seeds and pictures. The rule of dir: [avclass][range]@hhmmss. E.G., [aicheng_west][2~32]@124908/.
The default directory is home directory.

--hate
If you hate some subject topics, you can ignore them by setting this option with keywords in topic title, split by space-char ' ', and case sensitive. E.G., --hate 孕妇 重口味. When --hate keywords list conflict with --like, --hate first.

--like
If you like some subject topics, you can grab them by setting this option with keywords in topic title, split by space-char ' ', and case sensitive. E.G., --like 苍井空 小泽玛利亚. When --like keywords list conflict with --hate, --hate first.

--proxy
As you know, the government likes blocking adult websites, so, I do suggest you to set --proxy option. Hardseed supports more proxys:
a) GoAgent (STRONGLY recommended), --proxy http://127.0.0.1:8087
b) shadowsocks, --proxy socks5://127.0.0.1:1080, or socks5h://127.0.0.1:1080
c) SSH, --proxy socks4://127.0.0.1:7070
d) VPN (PPTP and openVPN), --proxy ""
It is important that you should know, you can set more proxys at the same time, split by space-char ' '. As the --concurrent-tasks option says, each proxy could more than one concurrent tasks, now, what about more proxys? Yes, yes, the speed of downloading seed and pictures is very very fast. E.G., --concurrent-tasks 8 --proxy http://127.0.0.1:8087 socks5://127.0.0.1:1080 socks4://127.0.0.1:7070, the number of concurrent tasks is 8*3.
If you wanna how to install and configure various kinds of proxy, please access my homepage "3.3 搭梯翻墙" http://www.yangyangwithgnu.net/the_new_world_linux/#index_3_3
The default http://127.0.0.1:8087.

That's all. Any suggestions let me know by yangyang.gnu@gmail.com or http://www.yangyangwithgnu.net/, big thanks to you. Kiddo, take care of your body. :-)


==================================================================================

硬盘女神,你懂嘀!hardseed 是个种子下载工具,它从浓(ai)情(cheng)蜜(she)意(qu)和爱(cao)意(liu)无(she)限(qu)的地方获取女神种子、图片。

【翻墙】
翻墙。你知道,这一切的一切都在墙外,所以你得具备翻墙环境,hardseed 才能正常帮你拉女神。hardseed 支持 GoAgent、shadowsocks、SSH、VPN (PPTP 和 openVPN)等各类代理模式,甚至你可以并行使用多种代理以极速下载。从普及度、稳定性、高效性来看,GoAgent 最优。“我一技术小白,工作压力大,就想看看女神轻松下,你还让我折腾代理?我恨你!”,嘚,亲,我错了。我帮你配置了一份开箱即用的 goagent,位于 hardseed/proxy/goagent/local/,linux 用户,命令行中运行 python proxy.py,windows 亲,双击运行 goagent.exe (管理员权限)。


【源码安装】

『windows』
这基本没 windows 用户什么事儿,除非你有 cygwin,否则你没法编译源码,没事,我服务很到位的,帮你弄好了,二进制执行程序位于 hardseed/bin/windows/hardseed.exe

『linux』
0)唯一依赖 libcurl,请自行安装;
1)代码采用 C++11 编写,gcc 版本不低于 4.7.1。
2)命令行下运行:
cd hardseed/build/
cmake .
make && make install

【使用】
听好,运行 hardseed 前务必确保代理软件已正常运行,否则,你碰不到任何女神。

『windows』
先进入 hardseed/bin/windows/,键入 ctrl-d 将光标定位到文件管理器的地址栏中,键入 CMD 启动命令行窗口,再 CMD 中键入
hardseed.exe
这时,hardseed 开始玩命儿为你下载女神图片和种子,约 1 分钟左右,在你 home 目录下会生成类似 C:\Users\Administrator\[aicheng_asia_mosaicked][1~128]@014822\ 的目录,女神们在此!

『linux』
同 windows 下运行一样,全用默认命令行参数运行
hardseed
执行完成后,你会看到 ~/[aicheng_asia_mosaicked][1~128]@014822/,你要的都在那儿。或者,玩点高级的
hardseed --saveas-path ~/downloads --topics-range 256 --av-class Aicheng_west
其中,--saveas-path 指定存放路径为 ~/downloads/;--topics-range 指定解析的帖子范围从第 1 张帖子到第 256 张帖子;--av-class 指定女神类型为欧美。

【演示】
47 changes: 47 additions & 0 deletions proxy/goagent/local/CA.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-----BEGIN CERTIFICATE-----
MIIDUjCCAjoCAQAwDQYJKoZIhvcNAQEFBQAwbzEVMBMGA1UECxMMR29BZ2VudCBS
b290MRAwDgYDVQQKEwdHb0FnZW50MRMwEQYDVQQDEwpHb0FnZW50IENBMREwDwYD
VQQIEwhJbnRlcm5ldDELMAkGA1UEBhMCQ04xDzANBgNVBAcTBkNlcm5ldDAeFw0x
MTA0MjAxNzM3MzVaFw0zMTA0MjAxNzM3MzVaMG8xFTATBgNVBAsTDEdvQWdlbnQg
Um9vdDEQMA4GA1UEChMHR29BZ2VudDETMBEGA1UEAxMKR29BZ2VudCBDQTERMA8G
A1UECBMISW50ZXJuZXQxCzAJBgNVBAYTAkNOMQ8wDQYDVQQHEwZDZXJuZXQwggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0jV3yx3yGAHlQqzm4fbVascvT
nyCdtParWBnQn5A3U9pJjI47SCo8j7FfeoYSL0mHbJ0mjafTnw+/ewb09AQIkdEl
n6smojl7NOKs1Yhh0yldB6kQWiBPr/X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O7OtTyYUWbLt1hvNkHlkNP8AjRQP8E
+N2jjrMAdbEwahPNAX9QlzHpF62AfEGQ3oODUm06TGTq+yAPSyYm
-----END RSA PRIVATE KEY-----
Binary file added proxy/goagent/local/GeoIP.dat
Binary file not shown.
7 changes: 7 additions & 0 deletions proxy/goagent/local/Microsoft.VC90.CRT.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<noInheritable/>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" />
<file name="msvcr90.dll" />
</assembly>
1 change: 1 addition & 0 deletions proxy/goagent/local/SwitchyOptions.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eyJjb25maWciOiJ7XCJmaXJzdFRpbWVcIjpcIjpdXCIsXCJwcm94eU1vZGVcIjpcImF1dG9cIixcImF1dG9QYWNTY3JpcHRQYXRoXCI6XCI6bWVtb3J5OlwiLFwicnVsZUxpc3RVcmxcIjpcImh0dHBzOi8vYXV0b3Byb3h5LWdmd2xpc3QuZ29vZ2xlY29kZS5jb20vc3ZuL3RydW5rL2dmd2xpc3QudHh0XCIsXCJydWxlTGlzdFJlbG9hZFwiOlwiNzIwXCIsXCJydWxlTGlzdFByb2ZpbGVJZFwiOlwiR29BZ2VudFwiLFwicnVsZUxpc3RBdXRvUHJveHlcIjp0cnVlLFwic3dpdGNoUnVsZXNcIjp0cnVlLFwicnVsZUxpc3RFbmFibGVkXCI6dHJ1ZSxcInBhY1NjcmlwdERhdGFcIjpcIlwiLFwicHJveHlTZXJ2ZXJcIjpcIlwiLFwicXVpY2tTd2l0Y2hcIjpmYWxzZSxcInF1aWNrU3dpdGNoVHlwZVwiOlwiYmluYXJ5XCIsXCJyZWFwcGx5U2Vs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CJwcm94eUNvbmZpZ1VybFwiOlwiOm1lbW9yeTpcIn0ifQ==
Binary file added proxy/goagent/local/SwitchySharp.crx
Binary file not shown.
Binary file added proxy/goagent/local/addto-startup.js
Binary file not shown.
125 changes: 125 additions & 0 deletions proxy/goagent/local/addto-startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env python
# coding:utf-8

from __future__ import with_statement

__version__ = '1.0'

import sys
import os
import re
import time
import ctypes
import platform

python2 = os.popen('python2 -V 2>&1').read().startswith('Python 2.') and 'python2' or 'python'

def addto_startup_linux():
filename = os.path.abspath(__file__)
dirname = os.path.dirname(filename)
#you can change it to 'proxy.py' if you like :)
scriptname = 'goagent-gtk.py'
DESKTOP_FILE = '''\
[Desktop Entry]
Type=Application
Categories=Network;Proxy;
Exec=/usr/bin/env %s "%s/%s"
Icon=%s/goagent-logo.png
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=GoAgent GTK
Comment=GoAgent GTK Launcher
''' % (python2, dirname , scriptname , dirname)
#sometimes maybe /etc/xdg/autostart , ~/.kde/Autostart/ , ~/.config/openbox/autostart
for dirname in map(os.path.expanduser, ['~/.config/autostart']):
if os.path.isdir(dirname):
filename = os.path.join(dirname, 'goagent-gtk.desktop')
with open(filename, 'w') as fp:
fp.write(DESKTOP_FILE)
# os.chmod(filename, 0755)


def addto_startup_osx():
if os.getuid() != 0:
print 'please use sudo run this script'
sys.exit()
import plistlib
plist = dict(
GroupName = 'wheel',
Label = 'org.goagent.macos',
ProgramArguments = list([
'/usr/bin/%s' % python2,
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'proxy.py')
]),
RunAtLoad = True,
UserName = 'root',
WorkingDirectory = os.path.dirname(__file__),
StandardOutPath = '/var/log/goagent.log',
StandardErrorPath = '/var/log/goagent.log',
KeepAlive = dict(
SuccessfulExit = False,
)
)
filename = '/Library/LaunchDaemons/org.goagent.macos.plist'
print 'write plist to %s' % filename
plistlib.writePlist(plist, filename)
print 'write plist to %s done' % filename
print 'Adding CA.crt to system keychain, You may need to input your password...'
cmd = 'sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "%s/CA.crt"' % os.path.abspath(os.path.dirname(__file__))
if os.system(cmd) != 0:
print 'Adding CA.crt to system keychain Failed!'
sys.exit(0)
print 'Adding CA.crt to system keychain Done'
print 'To start goagent right now, try this command: sudo launchctl load /Library/LaunchDaemons/org.goagent.macos.plist'
print 'To checkout log file: using Console.app to locate /var/log/goagent.log'

install_sharp_osx()


def install_sharp_osx():
# extracted from SwitchySharp.crx
extension_id = 'dpplabbmogkhghncfbfdeeokoefdjegm'
extension_version = '1.10.2'
extension_path = '%s/SwitchySharp.crx' % os.path.abspath(os.path.dirname(__file__))

dest_path = '/Library/Application Support/Google/Chrome/External Extensions'
dest_file = '%s/%s.json' % (dest_path, extension_id)
print 'Installing SwitchySharp for Chrome...'
cmd = 'mkdir -p "%s"' % dest_path
if os.system(cmd) != 0:
print 'Create Chrome External Extensions folder Failed!'
sys.exit(0)

json_dict = {'external_crx': extension_path,
'external_version': extension_version}
with open(dest_file, 'w') as fp:
import json
json.dump(json_dict, fp)
print 'Installing SwitchySharp done.'


def addto_startup_windows():
if 1 == ctypes.windll.user32.MessageBoxW(None, u'是否将goagent.exe加入到启动项?', u'GoAgent 对话框', 1):
if 1 == ctypes.windll.user32.MessageBoxW(None, u'是否显示托盘区图标?', u'GoAgent 对话框', 1):
pass


def addto_startup_unknown():
print '*** error: Unknown system'


def main():
addto_startup_funcs = {
'Darwin' : addto_startup_osx,
'Windows' : addto_startup_windows,
'Linux' : addto_startup_linux,
}
addto_startup_funcs.get(platform.system(), addto_startup_unknown)()


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
Loading

0 comments on commit 08453eb

Please sign in to comment.