采集指定域名邮箱用于社工或者fuzz的PHP小脚本
只写了百度的规则,GOOGLE抓取搜索地址后自己写。我的思路是禁止javascript来得到返回的内容。
配合生成弱口令的小脚本进行爆破效果应该不错。
效果图如下:
代码如下:
<?php
class search
{
private $engine = array();
private $fp = null;
public function __construct()
{
$this->set('baidu', 'http://www.baidu.com/');
//$this->set('google','https://www.google.com.hk/');
//$this->set('360','http://www.so.com/');
//$this->set('sogou','http://www.sogou.com/');
}
/**
* @param string $key 要搜索的关键词
* @param string $bind 抓取指定域名的email,不填则抓取关键词的所有email
*/
public function run($key, $bind = false)
{
$this->fp = fopen('email.txt', 'a+');
foreach ($this->engine as $engine => $url) {
$this->rule($engine, $url, $key, $bind);
}
fclose($this->fp);
$data = file('email.txt');
$email = array_unique($data);
file_put_contents('email.txt', null); //清空email
foreach ($email as $v) {
file_put_contents('email.txt', $v, FILE_APPEND); //追加重写非重复email
}
}
private function curl($urls, $engine, $bind = false)
{
$queue = curl_multi_init();
$map = array();
foreach ($urls as $url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_NOSIGNAL, true);
curl_multi_add_handle($queue, $ch);
$map[(string) $ch] = $url;
}
$responses = array();
do {
while (($code = curl_multi_exec($queue, $active)) == CURLM_CALL_MULTI_PERFORM);
if ($code != CURLM_OK) {
break;
}
while ($done = curl_multi_info_read($queue)) {
//$info = curl_getinfo($done['handle']);
//$error = curl_error($done['handle']);
$results = $this->callback(curl_multi_getcontent($done['handle']), $engine, $bind);
//$responses[$map[(string) $done['handle']]] = compact('info', 'error', 'results');
$responses[$map[(string) $done['handle']]] = $results;
curl_multi_remove_handle($queue, $done['handle']);
curl_close($done['handle']);
}
if ($active > 0) {
curl_multi_select($queue, 0.5);
}
} while ($active);
curl_multi_close($queue);
return $responses;
}
private function set($name, $url)
{
$this->engine[$name] = $url;
}
/**
* 读取规则
* @param integer $pn 百度的记录数,180表示18页,好像百度做了限制一次只能抓取么多.
*/
private function rule($engine, $url, $key, $bind = false)
{
switch ($engine) {
case 'baidu':
for ($pn = 0; $pn <= 180; $pn = $pn + 10) {
$urls[] = $url . 's?nojs=1&pn=' . $pn . '&wd=' . urlencode($key);
}
$this->curl($urls, $engine, $bind);
break;
case 'google':
break;
case '360':
break;
case 'sogou':
break;
}
}
/**
* 匹配规则
*/
private function callback($data, $engine, $bind = false)
{
switch ($engine) {
case 'baidu':
$replace = preg_replace('~</?em>~i', '', $data); //去掉搜索飘红提示
if (preg_match_all('~[(a-z0-9_)]+?(?<!b3Db)[@#][a-z0-9_]+?(.[a-z]{2,3}){1,2}~i', $replace, $email)) {
foreach ($email[0] as $v) {
$v = str_replace('#', '@', $v);
$bool = $bind ? strpos($v, $bind) : true;
if ( $bool !== false) {
fwrite($this->fp, $v . "rn");
echo 'Writed ' . $v . "<br>";
}
}
}
break;
case 'google':
break;
case '360':
break;
case 'sogou':
break;
}
}
}
ignore_user_abort(true);
set_time_limit(0);
$search = new search;
$search->run('@ucloud.cn','ucloud.cn');
//$search->run('@ucloud.cn');
?>
已实际测试可用,并且可根据自己的需要进行改进。

《 “[collect]采集指定域名邮箱[bak]” 》 有 5 条评论
`
Google/Shodan/LeakedSource/微步在线
theHarvester/SimplyEmail/Infoga
`
https://github.com/laramies/theHarvester
https://github.com/killswitch-GUI/SimplyEmail
https://github.com/m4ll0k/Infoga
https://github.com/achillean/shodan-python
Teemo:域名收集及枚举工具(搜索引擎、第三方站点、暴力枚举)
http://www.polaris-lab.com/index.php/archives/101/
https://github.com/bit4woo/Teemo #域名收集途径思维导图
Cr3dOv3r – 根据邮箱自动搜索泄漏的密码信息,也可测试账户密码在各大网站能否登录的工具
https://github.com/D4Vinci/Cr3dOv3r
通过脉脉用户猜测企业邮箱
https://github.com/Ridter/Mailget
LinkedIn Recon Tool
https://github.com/vysec/LinkedInt
https://vincentyiu.co.uk/maiint-profiling-china-based-employees/
一个简单的现代化公司域名使用规律预测及生成工具
https://github.com/LandGrey/domainNamePredictor
`
# 什么是域名预测?
简答来讲就是基于 “现代化” 公司比较规范的域名使用规律已经使用的新技术架构,在已知某个域名后,预测该域名可能有哪些变体形式的域名。
举一个简单的例子:
已知 A 公司有一个域名 shoot.A.com,那么对应的接口服务域名可能是 api.shoot.A.com、 shoot.restful-api.A.com、 shoot-api.A.com 等;
测试、预发等不同环境的域名可能是
shoot-api.test.A.com 、 test.api.shoot.A.com 、 pre.shoot-api.A.com 等;
对应的不同环境的管理监控域名可能是 shoot-monitor.dev.A.com 、shoot-dev-monitor.A.com 、st1.shoot-dashboard.A.com 等;
对应不同负载代理的域名可能是 shoot-api.corp.A.com 、 api.shoot.internal.A.com 等;
对应的后端 api 服务生产环境的域名可能是 backend-api.prod.shoot.A.com、 backend-api-prod.shoot.A.com等。
当然,在缺少域名前缀,仅知道域名为 A.com 时,也可以按照此规律直接进行预测。
# 为什么要写这个工具?
随着对许多 “现代化” 业务的接触和实际渗透测试,我发现在域名的探测这个很小的领域中,现有的子域名爆破、第三方服务接口查询都不能很好的覆盖到 域名预测 这个概念。
这样当你得到 shoot.A.com 域名后,很可能会遗漏上面举例中的相关重要域名,导致 “灯下黑”。
# 这个工具可以干什么?
按照配置文件和生成规则来完成上述的域名预测,生成完整的域名字典。
目前一个域名在 simple 规则下大概生成 6w—7w 左右个域名,在 default 规则下生成 26w—29w 个域名。
生成完域名后可以用支持完整域名验证的工具去验证域名是否存在,比如使用 ksubdomain 命令 subdomain -f predictor-domains.txt -verify 。
`