how do you execute a php script on a site thats not mine?i need to know this because, i found in a site where you have to multiply 2 large numbers and find its product within 1 sec....a normal man can't do this even with the help of a calculator, because what they meant was to program and find out the result...i know how to write that script but don't know where to put that script in that site and execute....any suggestions gladly accepted...
you can use php curl remote server access. but you must have the permission
I would check out the source of the page, and write a javascript to pull the numbers from the page and submit the answer.
You can use a Firefox addon such as Greasemonkey to run the script on the page.
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
If the site you need to submit the answer to uses a form, it might be possible to write your own form and post it to that site. Most sites block that kind of behavior though.
Related
I got a theoretic question.
If I use a form with GET method that is leading for an external PHP file (test.php),
I suppose anyone can find out what would be the result simply by viewing the source page, getting the variables (e.g., action="test.php" name="do" value="hello"), and then typing the URL with these variables:
....test.php?do=hello
I mean, he wouldn't have to actually click the button on the original page in order to find out what happens.
However, is there anyway to know what would be the result of a POST method button, without clicking it?
Your question has two possible meanings.
One is discover what the page does, what is the result of processing. That can be found by almost anybody with enough knowledge and tools to send a post request. There are a bunch of tools that allow you to do that. You can do it with plugins for your browser, security analysing tools like webscarab, programming languages using cURL, etc.
The second meaning is determining how the result was achieved. That, is not possible to know unless the source code of the processing file is accessed and analysed.
I am a complete PHP novice and I am just trying to write a simple web form and script that checks to see if the input matches a specific string. I have got that working no problem and just want to know if there is some way for the web form user to parse the script code and see what I am comparing to, therefore revealing the secret message to them.
Thanks in advance.
If there is a missconfiguration with your apache server, then it is a possibility. But other than that, PHP is server-sided scripting and will remain visible to only the server/FTP users.
Let me just start by saying I know almost nothing about PHP but, I think that may prove to be the best way to do what I'm trying to do. I'd like to grab the value of a variable from an external page so that I can then process it for the creation of graphs and statistics on my page. An example page that I'm trying to get the variable from (requires a Facebook Account) is - http://superherocity.klicknation.com/game/pages/battle_replay.php?battle=857337182
The variable name is fvars and it contains data about what the 2 players used for attacks, how much damage they did, etc. Ultimately what I'd like is to provide a page with a form where a player can go and plug in their replay link (like above) and get a nice neat detailed breakdown of the battle.
At the very least, if someone could explain to me how to just echo out the value of fvars after a form submission with the replay url as input it would help out immensely!!! I've tried looking at some PHP references and other posts here but, have so far been lost. :(
Thank you for any help or guidance.
One way you could approach it is to use Selenium. You would need to setup the selenium server and a browser and then write a selenium script to fetch the page for you. The key point here is that selenium can run a firefox client with javascripts, facebook logins etc, everything you have on your ordinary firefox, through selenium programmatically.
I run selenium in a Linux environment and control it through php cli scripts. I run the java selenium-server-standalone along with framebuffered X and firefox. PHP Unit test library allready has an extension though you wouldn't need it for testing obviously.
You can get the contents of any webpage like so:
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
And then just use regex or basic searching to find the variable you need in $homepage. The problem is that you need to be logged in via Facebook. I know of no current way to do this dynamically with PHP.
Mike
Edit: found an SO question that addresses this exact issue - Scraping from a website that requires a login?
I was wondering, I want to plant a JS tracking code (analytics) in a few websites to track their traffic. But I don't want that when viewing the site's source code people will be able to see that I've embedded the JS tracking code there.
Is it possible? Maybe by using an Apache/PHP trick?
Thanks,
Roy.
Nope it's not possible, for the browser to execute any code at least some of it must be initially visible, even if that code is to then retrieve the tracking code itself.
In addition all the modern web developer tools provide access to any code that is loaded so anyone can use those to see anything you've attempted to load discretely.
The more important question is why you want to hide that you're tracking people?
It's not absolutely possible with Javascript. Javascript always runs in the context of the user's browser, so it always means that the user will have access to see the script. You can obfuscate it, or try some tricks similar to anti-hotlinking on the JS code, but it will still be relatively easy for someone to figure out what the code does with a simple tool like Firebug.
You can, however, track your traffic without JavaScript. Analytics uses JavaScript for portability, and because some of the data it accesses can only be accessed with JavaScript. However, there are more passive ways of tracking your traffic which don't require JavaScript, such as any log analyzer like AWstats. You just don't get some of the cool features of Analytics.
It's not possible, but you could just name your script file something innocent like "mouseover.js".
It's not possible: JS code has to be run by the web browser, which means that -- which ever way you try put it -- it has to be readable by the browser and thus by anyone that inspects the page.
You could try obfuscating the JS, but that won't stop anyone that is determined to see what's happening.
You could ask yourself what the odds are that more than a few people will check whether you're tracking them -- I wouldn't expect it.
You can't technically hide the code... But you can scramble it so it's not readable to anybody. I used http://hivelogic.com/enkoder/form by Dan Benjamin to scrable some JS on my page (in this case I scrambled my email address). It scrambles it so the browser can execute it, but it's not humanly readable...
Then you can just call it as a function like I did in from this script http://www.jamischarles.com/css_js/email_encoder.js. Give it a try.
Just wondering if it's possible to screen grab a page you are viewing with a PHP script or javascript? For example, load up a page in an iframe and then save that view as a JPEG?
I'm sure it's possible somehow, but are there any known implementations/libraries that help out?
Nope, sorry, it is impossible with Javascript and definitely impossible with a server-side language like PHP. (Edit: I mean it's impossible to take a screenshot of the user's view of the page.)
It depends on what you want to do this for, but you might want to find a script or program that runs server-side and renders the webpage there. But if you really want to take the screenshot of the user's view of the page, it's pretty much impossible.
http://html2canvas.hertzen.com/ might do the trick.
There is a python tool called Webkit2png, hope it helps. But in PHP, i don't believe its possible
You can't do it in JS but you could do something similiar server side if you know the url of the page you want to convert to an image.
Tools like khtml2png could be called from php to render the page.
Possible with the GD2 extension and some knowledge of the internals you are capturing - read here for an example.
Thanks for the help guys. I did find this interesting resource:
http://www.zubrag.com/scripts/website-thumbnail-generator.php
It's not PHP specific by any means, just an example of running an EXE script that is called by PHP. Needs a windows server I believe though.