🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
4 messages
4 total messages Started by riv Fri, 11 Sep 2009 11:17
Problem z JS
#49300
Author: riv
Date: Fri, 11 Sep 2009 11:17
113 lines
4460 bytes
Witajcie,

pracuję nad małym programem w Ruby & Mechanize. Podczas pracy
natknąłem się na mały problem, mianowicie: używając Mechanize chcę
wysłać formę - jest to rzecz banalnie prosta, jednak dopóki nie
zostaną kliknięte reklamy - forma nie może zostać wysłana.
Zabezpieczenie ma postać licznika kontrolowanego przez JS - jeśli nie
osiągnie stanu X/X kliniętych - forma nie może zostać wysłana -> JS
nie zwraca 'true' do formy.
Sądziłem, że zabezpieczenie działa tylko w GUI, jednak wygląda na to,
że nie.

Moje pytanie brzmi: czy istnieje możliwość 'oszukania' JS w taki
sposób aby wysłanie formy stało się możliwe?

Poniżej zamieszczam to, co udało mi się 'wyciągnąć' z witryny:

kod samego licznika (raczej mało ważny):
> [Count: <span id="thenum">0</span>2]

kod reklam do kliknięcia:
> <tr>
>	<td><iframe id="baidu9" src='plugins/jswork/data/baidu/9.htm' ></iframe></td>
> </tr>
> <tr>
>	<td><iframe id="baidu7"  src='plugins/jswork/data/baidu/7.htm' ></iframe></td>
> </tr>
pliki htm zawierają tylko tag <a href> z grafiką, otwierane z
atrybutem "_blank"

kod formy, którą staram się wysłać:
<form name="clickform" action="plugin.php?
identifier=jswork&amp;module=jswork&amp;action=get" method="post"
onSubmit="return checkclick();"><input class="submit" type="submit"
value="Submit">
</form>

kod pliku 'click.js' który jest zawarty w html-u:

document.write('<script id=click></script>');
var elements_id = document.getElementsByTagName("iframe");
var theclick=new Array(elements_id.length);
var adid=new RegExp(/baidu(\d+)/);
var thenum=document.getElementById("thenum");
var themsg=document.getElementById("themsg");

for (var i = 0; i < elements_id.length; i++)
{
	var result=null;
	var elementid=elements_id[i].id;
	result=elementid.match(adid);
	if(result != null){
		var id=result[1];
		theclick[id]=0;
		elements_id[i].onfocus = clickad;
	}

}
function clickad(){
	var adid=new RegExp(/baidu(\d+)/);
	var theid=document.activeElement.id;
	var result=null;
	var ad_count=0;
	result=theid.match(adid);
	if(result!=null){
		id=result[1];
		theclick[id]=1;
		for(var i=0; i<theclick.length; i++){
			if(theclick[i]==1) ad_count++;
		}
		bug = new Image();
		bug.src='plugin.php?
identifier=jswork&module=jswork&action=click&id='+id;
		thenum.firstChild.data=ad_count;
	}
}



function clicks(id){
	theclick[id]=1;
	var ad_count=0;
	for(var i=0; i<theclick.length; i++){
		if(theclick[i]==1) ad_count++;
	}
	bug = new Image();
	bug.src='plugin.php?
identifier=jswork&module=jswork&action=click&id='+id;
	thenum.firstChild.data=ad_count;
	thenum.appendChild(msg);

}

oraz kod skryptu odpowiedzialnego za funkcję 'checkclick':

function checkclick(){
	if(thenum.firstChild.data<5){
		alert("You have not finished the job yet.");
		return false;
	}else{
		return true;
	}
}
var a=document.getElementsByTagName('a');
for(var i=0;i<a.length;i++){
	var lk=a[i];
	lk.setAttribute("target","_blank");
}

___________________________________________________________________

O ile to możliwe, bardzo proszę o pomoc - niestety w zakresie
JavaScript jestem totalnym amatorem
Re: Problem z JS
#49301
Author: William Bonawentura
Date: Fri, 11 Sep 2009 12:05
2 lines
1065 bytes
Nie analizuj js tylko komunikację z serwerem. Zainstaluj sobie Live HTTP 
Headers 
Re: Problem z JS
#49303
Author: fv
Date: Fri, 11 Sep 2009 12:57
13 lines
1297 bytes
riv wrote:
> Moje pytanie brzmi: czy istnieje możliwość 'oszukania' JS w taki
> sposób aby wysłanie formy stało się możliwe?

Javascript zawsze można oszukać. Jeśli nie ma komunikacji z serwerem po każdym kliknięciu
(skorzystaj z rady kolegi Williama) to wystarczy dowiedzieć się, jak powstaje stan końcowy działania
javascript.

-- 
fv
Xbox gamertag: fastviper PL
Moto: Suzuki GSX 650F
Auto: Nissan Primera 2,0
Re: Problem z JS
#49302
Author: riv
Date: Fri, 11 Sep 2009 12:59
202 lines
8362 bytes
On 11 Wrz, 14:05, "William Bonawentura" <n...@ipartners.pl> wrote:
> Nie analizuj js tylko komunikację z serwerem. Zainstaluj sobie Live HTTP
> Headers

Dziękuję za poddanie pomysłu - rzeczywiście problem może leżeć w
wysyłanych nagłówkach.

Oto, co udało mi się przejąć (niestety Live HTTP Headers nie pracują z
IETab, FireFox nie sprawdza się w obsłudze tego skryptu) przy pomocy
IE Live HTTP Headers:

<----------------------- HEADERS ------------------------------>
GET /bbs/plugin.php?identifier=jswork&module=jswork&action=click&id=4
HTTP/1.1
Accept: */*
Referer: http://www.l2021.com/bbs/plugin.php?identifier=jswork&module=jswork
Accept-Language: pl
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; FDM)
Host: www.l2021.com
Connection: Keep-Alive
Cookie: checkpm=1; 819_smile=1DD0D7; 819_cookietime=2592000;
819_onlineusernum=75; PHPSESSID=d9a3d60906a036d8a4f80cc02bdafa8b;
819_sid=Iy54m8;
819_auth=71448umXx0sYHV2w3LyQAySWj4AiaFuoLFnBl0T7eZINhEkvUxnbcA91eUD65jzQvkYKsC3JP
%2F8kfGDbWxKGexGm8yw

HTTP/1.1 200 OK
Connection: close
Date: Fri, 11 Sep 2009 12:32:16 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: PHP/5.2.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Set-Cookie: clickad_gettime=1252672336; expires=Fri, 11-Sep-2009
12:37:16 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Content-type: text/html

GET /bbs/plugin.php?identifier=jswork&module=jswork&action=click&id=5
HTTP/1.1
Accept: */*
Referer: http://www.l2021.com/bbs/plugin.php?identifier=jswork&module=jswork
Accept-Language: pl
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; FDM)
Host: www.l2021.com
Connection: Keep-Alive
Cookie: clickad_gettime=1252672336; 819_smile=1DD0D7;
819_cookietime=2592000; 819_onlineusernum=75;
PHPSESSID=d9a3d60906a036d8a4f80cc02bdafa8b; 819_sid=Iy54m8;
819_auth=71448umXx0sYHV2w3LyQAySWj4AiaFuoLFnBl0T7eZINhEkvUxnbcA91eUD65jzQvkYKsC3JP
%2F8kfGDbWxKGexGm8yw

HTTP/1.1 200 OK
Connection: close
Date: Fri, 11 Sep 2009 12:33:05 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: PHP/5.2.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Set-Cookie: clickad_gettime=1252672385; expires=Fri, 11-Sep-2009
12:38:05 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Content-type: text/html

GET /bbs/plugin.php?identifier=jswork&module=jswork&action=click&id=8
HTTP/1.1
Accept: */*
Referer: http://www.l2021.com/bbs/plugin.php?identifier=jswork&module=jswork
Accept-Language: pl
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; FDM)
Host: www.l2021.com
Connection: Keep-Alive
Cookie: clickad_gettime=1252672385; 819_smile=1DD0D7;
819_cookietime=2592000; 819_onlineusernum=75;
PHPSESSID=d9a3d60906a036d8a4f80cc02bdafa8b; 819_sid=Iy54m8;
819_auth=71448umXx0sYHV2w3LyQAySWj4AiaFuoLFnBl0T7eZINhEkvUxnbcA91eUD65jzQvkYKsC3JP
%2F8kfGDbWxKGexGm8yw

HTTP/1.1 200 OK
Connection: close
Date: Fri, 11 Sep 2009 12:33:08 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: PHP/5.2.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Set-Cookie: clickad_gettime=1252672388; expires=Fri, 11-Sep-2009
12:38:08 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Content-type: text/html

GET /bbs/plugin.php?identifier=jswork&module=jswork&action=click&id=7
HTTP/1.1
Accept: */*
Referer: http://www.l2021.com/bbs/plugin.php?identifier=jswork&module=jswork
Accept-Language: pl
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; FDM)
Host: www.l2021.com
Connection: Keep-Alive
Cookie: clickad_gettime=1252672388; 819_smile=1DD0D7;
819_cookietime=2592000; 819_onlineusernum=75;
PHPSESSID=d9a3d60906a036d8a4f80cc02bdafa8b; 819_sid=Iy54m8;
819_auth=71448umXx0sYHV2w3LyQAySWj4AiaFuoLFnBl0T7eZINhEkvUxnbcA91eUD65jzQvkYKsC3JP
%2F8kfGDbWxKGexGm8yw

HTTP/1.1 200 OK
Connection: close
Date: Fri, 11 Sep 2009 12:33:10 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: PHP/5.2.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Set-Cookie: clickad_gettime=1252672390; expires=Fri, 11-Sep-2009
12:38:10 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Content-type: text/html

GET /bbs/plugin.php?identifier=jswork&module=jswork&action=click&id=9
HTTP/1.1
Accept: */*
Referer: http://www.l2021.com/bbs/plugin.php?identifier=jswork&module=jswork
Accept-Language: pl
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; FDM)
Host: www.l2021.com
Connection: Keep-Alive
Cookie: clickad_gettime=1252672390; 819_smile=1DD0D7;
819_cookietime=2592000; 819_onlineusernum=75;
PHPSESSID=d9a3d60906a036d8a4f80cc02bdafa8b; 819_sid=Iy54m8;
819_auth=71448umXx0sYHV2w3LyQAySWj4AiaFuoLFnBl0T7eZINhEkvUxnbcA91eUD65jzQvkYKsC3JP
%2F8kfGDbWxKGexGm8yw

HTTP/1.1 200 OK
Connection: close
Date: Fri, 11 Sep 2009 12:33:12 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: PHP/5.2.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Set-Cookie: clickad_gettime=1252672392; expires=Fri, 11-Sep-2009
12:38:12 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Content-type: text/html

POST /bbs/plugin.php?identifier=jswork&module=jswork&action=get HTTP/
1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/x-ms-application,
application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml
+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint,
application/msword, */*
Referer: http://www.l2021.com/bbs/plugin.php?identifier=jswork&module=jswork
Accept-Language: pl
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; FDM)
Host: www.l2021.com
Content-Length: 0
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: clickad_gettime=1252672392; 819_smile=1DD0D7;
819_cookietime=2592000; 819_onlineusernum=75;
PHPSESSID=d9a3d60906a036d8a4f80cc02bdafa8b; 819_sid=Iy54m8;
819_auth=71448umXx0sYHV2w3LyQAySWj4AiaFuoLFnBl0T7eZINhEkvUxnbcA91eUD65jzQvkYKsC3JP
%2F8kfGDbWxKGexGm8yw

<---------------------END:HEADERS-------------------------->

Wygląda na to, że poprzez kliknięcia na reklamy do serwera są wysyłane
'potwierdzenia' typu: 'GET /bbs/plugin.php?
identifier=jswork&module=jswork&action=click&id=9' w zależności od ID
wyświetlanej reklamy. Podejrzewam, że wysłanie odpowiednich
'potwierdzeń' w zależności od zawartości strony rozwiąże problem
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads