Results 1 to 7 of 7

Thread: Security help

  1. #1
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default Security help

    Before I start, let me say that I know JS stinks as a security system for websites because it can be hacked into, but I am experimenting with it, as sort of a way to see what JS can do.

    My idea is that users have a security card (such as a USB Drive with the JS file on it) that they plug in to unlock pages in the site. This process has proved to be complicated though--I have run into several problems.

    First (simple problem but I didn't see it on the forum), how do you search an array? (i.e. var code= new array("01", "02", "03"), how do you search it for, say, a var named accessString?)

    Second, how can I write to a external js file, and not only that but define where I want to write in that JS file? (i.e. write "01234" on lane 18, character 23 of keystart.js) Is that even possible?

    Thanks!
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    First (simple problem but I didn't see it on the forum), how do you search an array? (i.e. var code= new array("01", "02", "03"), how do you search it for, say, a var named accessString?)
    There is a method of Array called indexOf, which works similarly to that of a string. However, it's not implemented in JScript, so it's necessary to implement it in script:
    Code:
    if(typeof Array.prototype.indexOf !== "function")
      Array.prototype.indexOf = function(needle) {
        for(var i = 0; i < this.length; ++i)
          if(this[i] == needle)
            return i;
        return -1;
      }
    Second, how can I write to a external js file, and not only that but define where I want to write in that JS file? (i.e. write "01234" on lane 18, character 23 of keystart.js) Is that even possible?
    Not reliably. It's possible using ActiveX or Java, but rather pointless when it's so much simpler to do it server-side.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thanks Twey
    I'll have to check out the indexOf.

    So suppose that I don't care about reliability =P
    How could I get the writing in external JS file to work?
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You could just create the file instead... might be a BIT easier.

    Not really sure about java/activex myself. Seems complex to me too.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You'd need to create and sign a Java applet, or use an ActiveX object as explained in this article. Since you're only experimenting, the latter option is probably simpler, but of course it only works on IE.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    Thanks again, but I think I'm more lost now. . . I guess I'll have to study. . .
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  7. #7
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    One more thing, how do I get the indexOf thing to work? I can't figure it out. . . Newbie. . .
    (The var = accessString, the string = code)
    Or if you know a good tutorial
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •