Tuesday, August 23, 2011

Port Redirection

I had a need to access remote UDP ports that were not open through my VPN connection. I thought no problem I will just configure my ssh connection to tunnel those ports! I quickly found that traditional SSH port forwarding does not support UDP. So I had to find a work around.

In order to tunnel UDP requests through SSH you need to find unused TCP ports on your local and remote machines and configure them to forward requests to the UDP ports that you need to access. This can be accomplished using socat or nc on *NIX machines.

Found a neat utility to ease the process of network port forwarding in Windows.

http://www.quantumg.net/portforward.php


Monday, January 10, 2011

Utility to track statistics from multiple Windows Servers

Logman creates and manages Event Trace Session and Performance logs and supports many functions of Performance Monitor from the command line.


C:\Users\dsides>logman -?


Microsoft r Logman.exe (6.1.7600.16385)


Usage:
  logman [create|query|start|stop|delete|update|import|export] [options]


Verbs:
  create                        Create a new data collector.
  query                         Query data collector properties. If no name is given all data collectors are listed.
  start                         Start an existing data collector and set the begin time to manual.
  stop                          Stop an existing data collector and set the end time to manual.
  delete                        Delete an existing data collector.
  update                        Update an existing data collector's properties.
  import                        Import a data collector set from an XML file.
  export                        Export a data collector set to an XML file.


Adverbs:
  counter                       Create a counter data collector.
  trace                         Create a trace data collector.
  alert                         Create an alert data collector.
  cfg                           Create a configuration data collector.
  providers                     Show registered providers.


Options (counter):
  -c        Performance counters to collect.
  -cf                File listing performance counters to collect, one per line.
  -f  Specifies the log format for the data collector. For SQL database format, you must
                                use the -o option in the command line with the DNS!log option. The defaults is binary.
  -sc                   Maximum number of samples to collect with a performance counter data collector.
  -si <[[hh:]mm:]ss>            Sample interval for performance counter data collectors.


Options (trace):
  -f  Specifies the log format for the data collector. For SQL database format, you must
                                use the -o option in the command line with the DNS!log option. The defaults is binary.
  -mode            Event Trace Session logger mode. For more information visit -
                                http://go.microsoft.com/fwlink/?LinkID=136464
  -ct       Specifies the clock resolution to use when logging the time stamp for each event.
                                You can use query performance counter, system time, or CPU cycle.
  -ln             Logger name for Event Trace Sessions.
  -ft <[[hh:]mm:]ss>            Event Trace Session flush timer.
  -[-]p A single Event Trace provider to enable. The terms 'Flags' and 'Keywords' are
                                synonymous in this context.
  -pf                File listing multiple Event Trace providers to enable.
  -[-]rt                        Run the Event Trace Session in real-time mode.
  -[-]ul                        Run the Event Trace Session in user mode.
  -bs                   Event Trace Session buffer size in kb.
  -nb                 Number of Event Trace Session buffers.


Options (alert):
  -[-]el                        Enable/Disable event log reporting.
  -th Specify counters and their threshold values for and alert.
  -[-]rdcs               Data collector set to start when alert fires.
  -[-]tn                 Task to run when alert fires.
  -[-]targ           Task arguments.
  -si <[[hh:]mm:]ss>            Sample interval for performance counter data collectors.


Options (cfg):
  -[-]ni                        Enable/Disable network interface query.
  -reg      Registry values to collect.
  -mgt    WMI objects to collect.
  -ftc      Full path to the files to collect.


Options:
  -?                            Displays context sensitive help.
  -s                 Perform the command on specified remote system.
  -config            Settings file containing command options.
  [-n]                   Name of the target object.
  -pid                    Process identifier.
  -xml               Name of the XML file to import or export.
  -as                           Perform the requested operation asynchronously.
  -[-]u       User to Run As. Entering a * for the password produces a prompt for the password.
                                The password is not displayed when you type it at the password prompt.
  -m <[start] [stop]>           Change to manual start or stop instead of a scheduled begin or end time.
  -rf <[[hh:]mm:]ss>            Run the data collector for the specified period of time.
  -b  Begin the data collector at specified time.
  -e  End the data collector at specified time.
  -o             Path of the output log file or the DSN and log set name in a SQL database. The
                                default path is '%systemdrive%\PerfLogs\Admin'.
  -[-]r                         Repeat the data collector daily at the specified begin and end times.
  -[-]a                         Append to an existing log file.
  -[-]ow                        Overwrite an existing log file.
  -[-]v       Attach file versioning information to the end of the log name.
  -[-]rc                 Run the command specified each time the log is closed.
  -[-]max               Maximum log file size in MB or number of records for SQL logs.
  -[-]cnf <[[hh:]mm:]ss>        Create a new file when the specified time has elapsed or when the max size is
                                exceeded.
  -y                            Answer yes to all questions without prompting.
  -fd                           Flushes all the active buffers of an existing Event Trace Session to disk.
  -ets                          Send commands to Event Trace Sessions directly without saving or scheduling.


Note:
  Where [-] is listed, an extra - negates the option.
  For example --u turns off the -u option.


More Information:
  Microsoft TechNet - http://go.microsoft.com/fwlink/?LinkID=136332


Examples:
  logman start perf_log
  logman update perf_log -si 10 -f csv -v mmddhhmm
  logman create counter perf_log -c "\Processor(_Total)\% Processor Time"
  logman create counter perf_log -c "\Processor(_Total)\% Processor Time" -max 10 -rf 01:00
  logman create trace trace_log -nb 16 256 -bs 64 -o c:\logfile
  logman create alert new_alert -th "\Processor(_Total)\% Processor Time>50"
  logman create cfg cfg_log -reg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\\"
  logman create cfg cfg_log -mgt "root\cimv2:SELECT * FROM Win32_OperatingSystem"
  logman query providers
  logman query providers Microsoft-Windows-Diagnostics-Networking
  logman start process_trace -p Microsoft-Windows-Kernel-Process 0x10 win:Informational -ets
  logman start usermode_trace -p "Service Control Manager Trace" -ul -ets
  logman query usermode_trace -p "Service Control Manager Trace" -ul -ets
  logman stop usermode_trace -p "Service Control Manager Trace" -ul -ets
  logman start process_trace -p Microsoft-Windows-Kernel-Process -mode newfile -max 1 -o output%d.etl -ets
  logman start "NT Kernel Logger" -o log.etl -ets
  logman start "NT Kernel Logger" -p "Windows Kernel Trace" (process,thread) -ets

Wednesday, August 19, 2009

Stupidity Amazes Me!!!!

I was watching the news and saw the recent peaceful protesters bring firearms to rallies protesting Obama and the Second Amendment and I was amazed at the stupidity of it. How stupid are these people, giving politicians the political fodder they need to use against them?
That is about as smart as going to a bar next to a police station, stumbling back to your car, blowing your horn and driving off. Yes, you can go to a bar, yes you can blow your car horn and yes you can drive home. But it is bringing unneeded attention to yourself and begging for a police officer to pull you over. People like those I saw on TV are like that, they would go in to the bar, drink water, fake stumble out to the car, flip the cops off and drive off. They are sober, so everything is legal and when the cop rightfully pulls them over, they are going to yell that their rights have been violated and are being targeted by the police. Then you get things like ridiculous alcohol level laws and sobriety traffic checkpoints all because some dummies screwed it up for the rest of us (No I don't think that is how blood alcohol tests and sobriety checkpoints were started I am just using a parable here).
I support the 2nd Amendment, probably more than the average citizen, but I would not do anything as stupid as publicly carrying my legal weapon to a protest against the president, basically asking people to take my rights from me. I almost wonder if opponents of the 2nd Amendment paid some of these individuals to show up at these rallies to look stupid; one of the guys with the M4/AR-15 strapped on his back did not look comfortable at all with the weapon, just stupid no matter what and it hurts the rest of us. I know people are saying that is just proof that stupid people are allowed to own firearms and they should be confiscated, but we can not throw away what was given to us by our founding fathers because of a few idiots. If we do then what stops us from losing even more for our own "protection". Likke automobiles for example. I could legally buy a dump truck and drive it full speed through the middle of a crowded stadium during the Alabama vs Auburn or Ohio State vs. Michigan game and chances are I would hurt a lot more people than I could ever get with any semi-automatic firearm. More people are injured by stupid, careless drivers every year than ever get wounded by a firearm.  A true example is where a construction company owner, wielded steel around his bulldozer and took it on a destructive killing spree through the middle of a down town in the Midwest. Yes this has actually happened.  I can still buy a bulldozer of my own though.

Thoughts on Movie Advertisement

While watching TV tonight every station aired commercials for the new Brad Pitt movie every 30 minutes it seemed. The big line is
"We are interested in one thing, Killing Nazis"
I find this kind of funny, it doesn't disturb me at all, they were the enemy of the US during that time period. I saw the original "Inglorious Bastards" when I was about 9 or 10 on HBO (that is the first movie I remember having nudity in it from my youth, it made a lasting impression to say the least) . What does surprise me though, although it shouldn't, is where are all the do gooders who normally come out to say "you can't say that, you are going to offend the Germans", you know, the kind of people Hollywood is made up of. The kind of people who say eating meat is murder to animals.

What would happen if that same line was used every hour advertising for other movies about our wars against the Japanese, Koreans, Chinese, British, Iraqis, American Indians, Philippines, etc. (you name them and chances are high that the US Army has done away with a group of them, we are quite good at that, after all killing is the job of the military whether we acknowledge it or not. Any soldier active or not, remembers standing on the parade field and screaming at the top of their lungs "WHAT MAKE THE GRASS GROW GREEN, ........ THE BLOOD, THE BLOOD MAKES THE GRASS GROW GREEN". That is when the realization of you job duty as a soldier comes to the forefront)

I am just curious as to what would happen if any other former or current enemy of the US was targeted in this manner. Where are the people saying consider the feelings of the Germans, many people living in the US are former German Nazis, they were being loyal to their country at the time. I wonder what they think as they see that commercial hourly and remember their dead brothers who were justifiably slain by the American War machine.  If we can bring up those wounds to the Germans, why is it not ok to show video clips of the attack on the twin towers every hour to make us remember current events and why we need a strong defense and that their are very powerful forces out there who wish death and destruction upon us.

Since there are American Nazis, I do not agree with them by the way, and I think they are a sad ridiculous group (the original Nazis were for national socialism by the way, remind you of  some of our current politicians?), why can we say "We are in the business of killing Nazis" but if someone said the same thing and substituted another group, say Muslims, they would be chastised and branded hate mongers? All Muslims do not wish death and destruction on us, all Nazis did not wish it upon us either. I know an old man who was a member of the former Hitler youth, he says he didn't understand at that time what it was really about, but that he was wanting to defend those around him and be patriotic to his country, not necessarily kill people. He said most of those around him felt the same way he did, it was the radicals that you had to watch out for. Sounds familiar to current events doesn't it? But yet it is OK to label them and wish death upon them.

I am just wondering if anyone else finds it odd. Personally it doesn't bother me, I was just noticing how it seemed unfair for us not to be able to say we are in the business of killing our current enemies when it is okay to glorify our past victories of killing Nazis. As a closing statement I will say that when I joined the U.S. Army at 17 years old, I like every other soldier, swore an Oath to Protect the Constitution of the United States of America from ALL enemies foreign and domestic, so any enemy of the US and its Constitution (yes even domestic politicians) should be fair game. Things are different now then they were in the 1700's; unfortunately we can't tar and feather them anymore and get away with it; the only effective weapon we currently have against those domestic enemies of the Constitution is our vote, so in the next voting year I am going to vote against any incumbent politician (Republican or Democrat) who has voted against what was laid out by our founding fathers when they laid out our Constitution. I am scared I am in a losing battle for the first time in my life. Get on the "We are in the business of Killing Socialism" band wagon and stick up for what so many of our forefathers died for.

Tuesday, August 4, 2009

Email Attachments - Consider Before You Embed!

I recently received an email from someone in a storage related distribution list. At the bottom of the email it has this bitmap image embedded in the email (I have saved it as a png file to compress it without losing any of its original quality and save space).


The only thing that made me notice it was that the email showed that it had an attachment, the only attachment was this image. I then started thinking, why use an image to say this, that takes up unnecessary space. I looked at the email properties and found that the size of this email was 54 KB. Not too bad, but I looked at another much longer email that had no embedded images or files and saw that the average was 7 KB. I saved the attachment out and found that his embedded image was 28 KB by itself. There again, not a huge amount. Then I looked at how many people were on this distribution list (all of the recipients are on the same Exchange server) and found that there were roughly 2,500 people that received that email and attachment.With that one 28 KB attachment it has consumed around 70 MB of storage.
             28 KB * 2500 =  70,000Kb (68.4 MB)
Still not a whole lot. But, considering that I could go back and see that this same person has sent over 25 emails to this distribution list you now have 1.67 GB of storage consumed it is starting to look like a lot of wasted storage.
             68.4 * 25 =  1,708.98 MB (1.67 GB)
 
I know that I have seen this same attachment on a lot of emails not only from this poster but from others as well. If only 4 other users have this same embedded attachment and they send 10 emails each then they have consumed around 2.67 GB of storage for their attachment only. This does not include any actual useful data.
            4 * 28 KB = 112 KB
            10 * 112 KB = 1,120 KB
            1120 KB * 2500 = 2,800,000 KB (2,734.375 MB) or (2.67 GB)
If over a 6 month period these same 4 users send an additional 2500 emails  that has 10 people carbon copied then they have consumed yet another 2.67 GB bringing them up to 5.34 GB of storage! To put this into perspective an MP3 version of AC/DC's song Back in Black takes roughly 3.95MB of storage. You could store 1,367 copies of that song in the same amount of storage used for the attachment in this email.That is over 136 individual music CDs. If a storage administrator found a single user on this same Local Area Network storing 136 CDs on corporate owned storage it would be grounds for dismissal.

What makes this stand out to me is that this is a distribution for Storage Professionals, people who should understand the implications of extra data embedded into an email, I could understand if these were normal End Users, but not those whose job it is to minimize the amount of money spent on storing data. Maybe they should change their logo to a text version that states:
Consider Your Storage: Only include attachments when absolutely necessary to get your point across! And if you are going to print this email delete it from your inbox.

Thursday, July 30, 2009

NYTIMES : New Poll Finds Growing Unease on Health Plan

I wrote about statistics before but, this ending to an article refusing to say anything negative about the president says it all.I which finding the white house will be using.

In one finding, 75 percent of respondents said they were concerned that the cost of their own health care would eventually go up if the government did not create a system of providing health care for all Americans. But in another finding, 77 percent said they were concerned that the cost of health care would go up if the government did create such a system.

Friday, July 24, 2009

Massachusetts Says Encrypt It All!

A law that takes effect in Jan 2010 reads like this

  • "All persons that own, license, store or maintain personal information about a resident of the Commonwealth," which presumably means any business anywhere that does business with Massachusetts residents
  • Paper as well as electronic records
  • Secure user user authentication protocols
  • Secure access control measures
  • Encryption on all wireless networks linked to personal information repositories
  • Monitoring and encryption for all portable devices with personal information
  • Firewall protection for any database containing PII
  • System security software must be installed and kept up to date
  • Education and training is also required
It is pretty restrictive yet it is still open for interpretation and leaves a lot of leverage for prosecutors to go after a company that they want to bring down. If you have ever been involved with the PIN or SAS70 type audits then you know how these rules can be interpreted differently by any governing body. Bottom line is this is going to be VERY costly to many organizations. It is not a bad thing to a degree, but it will be costly and probably abused by law enforcement officials who do not understand how computer technologies actually work.

Sunday, July 19, 2009

CBS press Sotomayor about her 2ND Ammendment views and she refuses to answer

President Obama's first nominee to the high court did previously say that she believed Americans do not currently enjoy a fundamental right to bear arms, which echoes her two previous rulings on the topic as an appeals court judge. But now she refused to elaborate on her views about firearms regulations and the Second Amendment, saying she would "make no prejudgments" about future firearms-related cases.

New York Lawmakers

New York House Assembly actually has an annual "Anti-Gun Day" for enacting new laws in the state. This takes place every April 29th.

One of the crazy things being proposed for the next year is a mandate to modify handguns to make it impossible to be operated by children. It would require a 10lb trigger pull and require multiple motions in order to fire the weapon. Another requirement would be to require firearm retailers to carry insurance to cover any criminal acts committed after the sale of a firearm.

Sending email with attachments on UNIX systems

Sending email with attachments on UNIX systems
All of the below examples use the following shell variables. I use MIME type application/octet-stream just as an example. Actual type used will vary depending upon attachment file type. Remember, these are simple examples of the different tools available.

TXTFILE=/tmp/textfile  # A text message with a simple preface message
ATTFILE=/tmp/binary_file # File to be attached and generally requiring encoding
SUBJECT="Your attachment" # Change as needed
MAILTO=user@where.ever  # Ditto
  • uuencode – This is the original method to send encoded text within a message. It is not an attachment as we think of them today but is still used enough to warrant putting it here.
    uuencode $ATTFILE $ATTFILE | mail -s "$SUBJECT" $MAILTO
    (uuencode $FILE1 $FILE1; uuencode $FILE2 $FILE2) | mail -s "$SUBJECT" $MAILTO
     
  • simple shell commands – For a very simple text (plain or html) attachment with just one file:
    echo "From: $LOGNAME\nTo: $MAILTO\nSubject: $SUBJECT\n\
    Mime-Version: 1.0\nContent-Type: text/plain\n" > /tmp/file
    cat $TXTFILE >> /tmp/file
     
  •