Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - connection

Pages: 1 ... 3 4 [5] 6 7 8
61
PHP/Javascript / [Javascript] 10 super useful Javascript Snippets
« on: September 17, 2011, 12:06:36 am »
1. Email Validation

Source
Code: [Select]
function checkMail(email){
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(email)) {
return true;
}
return false;
}
2. Toogle Checkboxes

Source

Code: [Select]
<script type="text/javascript">

function toggle_checkboxes(id) {
    if (!document.getElementById){ return; }
    if (!document.getElementsByTagName){ return; }
    var inputs = document.getElementById(id).getElementsByTagName("input");
    for(var x=0; x < inputs.length; x++) {
        if (inputs[x].type == 'checkbox'){
            inputs[x].checked = !inputs[x].checked;
        }
    }
}

</script>

<div id="parent_box">

    <input type="checkbox" name="foo" value="1" /> 1<br/>
    <input type="checkbox" name="foo" value="2" checked="checked" /> 2<br/>
    <input type="checkbox" name="foo" value="3" checked="checked" /> 3<br/>

    <br/>
    <input type="button" value="Toggle checkboxes"
        onclick="toggle_checkboxes('parent_box')" />

</div>

3. Image Preloader

Source

Code: [Select]
var images = new Array();

function preloadImages(){
    for (i=0; i < preloadImages.arguments.length; i++){
         images[i] = new Image();
        images[i].src = preloadImages.arguments[i];
    }
}

preloadImages("logo.jpg", "main_bg.jpg", "body_bg.jpg", "header_bg.jpg");

4. Javascript cookies

Source

Code: [Select]
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
5. Sort Dropdown Menu

Source

Code: [Select]
function sortList(id) {
var obj = document.getElementById("id");
var values = new Array();
for(var i = 0; i < obj.options.length; i++) {
values.push(obj.options[i].innerHTML + "--xx--" + obj.options[i].value);
}

values = values.sort();

for(var i = 0; i < values.length; i++) {
valueArray = values[i].split('--xx--');
obj.options[i].innerHTML = valueArray[0];
obj.options[i].value = valueArray[1];
}
}

6. Determine if Browser Understands HTML5 Video

Source

Code: [Select]
// Check if the browser understands the video element.
function understands_video() {
  return !!document.createElement('video').canPlayType; // boolean
}

if ( !understands_video() ) {
// Must be older browser or IE.
// Maybe do something like hide custom
// HTML5 controls. Or whatever...
videoControls.style.display = 'none';
}

7. Get browser viewport width and height

Source

Code: [Select]
<script type="text/javascript">
<!--

 var viewportwidth;
 var viewportheight;

 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }

 // older versions of IE

 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
//-->
</script>

8. getElementsByClassName

Source

Code: [Select]
/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}

9. Delayed Redirect

Source

Code: [Select]
setTimeout( "window.location.href =
'http://walkerwines.com.au/'", 5*1000 );

10. iPhone Style Change on Orientation Change

Source

Code: [Select]
window.addEventListener('load', setOrientation, false);
window.addEventListener('orientationchange', setOrientation, false);

function setOrientation() {
 var orient = Math.abs(window.orientation) === 90 ? 'landscape' : 'portrait';
 var cl = document.body.className;
 cl = cl.replace(/portrait|landscape/, orient);
 document.body.className = cl;
}

62
General Discussion / Custom Gameboys
« on: September 14, 2011, 08:05:32 pm »
Hey guys I've started making custom gameboys and such as a hobby.

Here is my first one (not yet sealed since I somehow managed to forget to buy sealant).

Gameboy DMG-01 (Original, "Grey brick" Gameboy)








63
Other / PC Assembly Language Tutorial
« on: September 13, 2011, 05:50:05 pm »
Really good tutorial on coding in NASM for PC Assembly.

http://www.drpaulcarter.com/pcasm/

64
General Discussion / Bandai.com XSS
« on: September 13, 2011, 12:58:06 pm »
What do Power Rangers, Ben 10, Thundercats and Tamagotchi have in common? Bandai.com; well... and an XSS.

I reported the Bandi.com XSS about a month or so ago to Bandi but never got any reply. Yesterday I decided to test the vulnerability again only to find that it's still an issue. Here's the XSS announcement which they will hopefully eventually see and patch their site.

Proof:


PoC:
Visit http://bandai.com and then type '>"><script>alert(/HackTalk.net/.source);</script> into the search bar.

Enjoy

65
Other / Lua Tutorial
« on: September 13, 2011, 09:55:27 am »
Lua is a really great scripting language which is commonly used to create plugins and mods for online games (notable examples are Half-Life and WoW). It makes a great scripting language to know and is really easy for beginners to pick up.

http://lua-users.org/wiki/LuaTutorial

66
PHP/Javascript / [PHP] Login Script Tutorial
« on: September 12, 2011, 11:57:44 pm »
Really quick overview on a very basic login system using PHP and MySQL

http://www.phpeasystep.com/phptu/6.html

67
General Discussion / Warhammer 40k (table top)
« on: September 12, 2011, 11:59:03 am »
Anyone here play Warhammer 40k? The tabletop version not the PC version.

68
General Discussion / Wordpress Plugin Vulns
« on: September 10, 2011, 11:41:26 pm »
I just wanted to start this topic to discuss all the recent Wordpress vulnerabilities and really encourage you guys to start looking for vulns in popular plugins mainly because there are almost no vulns in the core code of Wordpress and by going through popular plugins even a simple XSS could lead to a pretty nice CSRF in Wordpress which would allow you to modify the stock Wordpress theme with a PHP backdoor and continue the pwnage.

Recently there haven't been many vulns in popular plugins but timthumb is an example of just how much pwnage can happen by finding a vuln outside of the core Wordpress code.

I'm totally down to help find vulns in plugins if you want to look for your own 0days but haven't done much of your own vuln research before.

69
General Discussion / Connection's Databent Photos
« on: September 10, 2011, 11:36:18 pm »
I recently got into databending and glitch art in general so I decided I'd share the pics I make along the way while I discover this artform with as little tutorials as possible.


70
General Discussion / Did Google Respond Appropriately?
« on: September 10, 2011, 02:03:59 pm »
If you haven't read the news about Google telling Iranian citizens that they should probably change their password, go read up on it here: http://thehackernews.com/2011/09/google-tells-iranians-to-change-their.html

I just wanted to know how you HackTalkers felt about Google's reaction; was it the right thing to do; was it executed properly; how do you feel?

71
Other / Batch Scripting for Beginners
« on: September 09, 2011, 01:02:42 pm »
Great guide if you are looking to get into Windows Batch scripting:

http://www.infionline.net/~wtnewton/batch/batguide.html

72
Other / Powershell Tutorial For Beginners
« on: September 09, 2011, 01:02:01 pm »
Great guide if you want to get into Powershell scripting in Windows:

http://www.powershellpro.com/powershell-tutorial-introduction/

73
Other / Advanced BASH Scripting Guide
« on: September 09, 2011, 12:27:07 pm »
This guide can be the difference between beginner BASH scripts and "omgwtfbbqchicken THAT'S AMAZING" scripts and really pushed my BASH scripting abilities to the next level.

http://tldp.org/LDP/abs/html/abs-guide.html

74
Other / BASH Guide for Beginners
« on: September 09, 2011, 12:25:27 pm »
When I started learning BASH scripting and making BASH oneliners this guide proved invaluable to me so I decided I'd share.

http://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html

75
Other / [BASH] Clear Exim Queue
« on: September 09, 2011, 12:23:28 pm »
Code: [Select]
exim -bp |awk {'print $3'} | xargs exim -Mrm
This is very useful for times when the queue is full of spam and you need to clear it before all the spam gets eventually sent out or if it's just full of a bunch of crap and is keeping mail from being sent out.

Pages: 1 ... 3 4 [5] 6 7 8

SimplePortal 2.3.3 © 2008-2010, SimplePortal