Server Archived Log Files

Uncategorized No Comments

We have a policy to retain our security log files for 90 days. Our domain policy is setup to auto archive the logs instead of overwriting them. The problem is that the 90 day rule doesn’t stick since there aren’t any entries in the current log file for longer than 90 days. Over the course of the year the log files will eventually fill up our servers c:\ drive.

A quick remedy….


forfiles -p "c:\windows\system32\winevt\logs" -s -m Archive-Security* -d -90 -c "cmd /c del @path"

Batch file to delete all but latest two files

Uncategorized No Comments


@echo off
set folder=C:\test

pushd "%folder%"
for /f "skip=2 tokens=*" %%i in ('dir /a:-d-s /b /o:-d') do echo "%%i"
popd

*** Stolen from Major Geeks forum member GermanOne

pfSense – Captive Portal

Uncategorized 1 Comment

To have reusable vouchers:

Edit /etc/inc/captiveportal.inc and modify:


/* This user was already logged in so we disconnect the old one */
captiveportal_disconnect($cpentry,$radiusservers,13);
captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - TERMINATING OLD SESSION");
unset($cpdb[$sid]);

with:


/* This user was already logged in so we disconnect the old one */
if (isset($config['captiveportal']['noconcurrentlogins']))  {
captiveportal_disconnect($cpentry,$radiusservers,13);
captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - TERMINATING OLD SESSION");
unset($cpdb[$sid]);
}

To get smaller voucher codes:

Generate new private and public key pair (can be done on any computer.)


openssl genrsa 31 > key.private
openssl rsa -in key.private -pubout -out key.public

Paste key.private and key.public in Services > Captive Portal > Vouchers under Voucher Public Key and Voucher Private Key.

I also changed the Character Set to: “2345678abcdefhjkmnpqrstuvwxyz”

It then generated 7 character voucher codes.

Grub2 Customizer

Linux No Comments

My previously written custom script to make Windows and Ubuntu show as the first two items in Grub no longer works after my latest install of Ubuntu 12.04. Looks like its back to using a utility to do the job.


sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

Taken from:
http://www.howtogeek.com/howto/43471/how-to-configure-the-linux-grub2-boot-menu-the-easy-way/

Disable IPv6 from CLI

Uncategorized No Comments

This must be run from a Administrator Command Prompt.


REG.EXE ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
\Tcpip6\Parameters /v "DisabledComponents" /t REG_DWORD /d 0xffffffff

Windows XP Add New Hardware USB

Uncategorized No Comments

Recently ran into a problem where an XP Machine was always popping up asking to install drivers for every little thing including USB Mouse and USB Mass Storage Device which shouldn’t ever happen. To fix it where it automatically installs the driver and assigns a drive letter go to the Command Prompt and type each of the following:


regsvr32 Softpub.dll
regsvr32 Wintrust.dll
regsvr32 Initpki.dll
regsvr32 Dssenh.dll
regsvr32 Rsaenh.dll
regsvr32 Gpkcsp.dll
regsvr32 Sccbase.dll
regsvr32 Slbcsp.dll
regsvr32 Mssip32.dll
regsvr32 Cryptdlg.dll

Software Activation Workaround

Windows No Comments

Was working in a local Dr. Office who is no longer paying a subscription/maintenance on their software since I am now taking care of supporting them. All of a sudden, without warning, their software required activation. I have saved the activation file for the server but this time it didn’t work to just put the file back. Turns out it was connecting back to their activation server. I ended up tracking down the solution with…


c:\>ipconfig /displaydns

Windows IP Configuration

         activate.softwareco.com
         ----------------------------------------
         Record Name . . . . . : activate.softwareco.com
         Record Type . . . . . : 1
         Time To Live  . . . . : 601260
         Data Length . . . . . : 4
         Section . . . . . . . : Answer
         A (Host) Record . . . : 8.8.8.8

c:\>

At this point I knew that it was resolving “activate.softwareco.com”. I simply added the following line to the hosts file and the server no longer checks for activation and my LEGIT license file still works!


127.0.0.1	 activate.softwareco.com
*Obviously for privacy and security the “activate.softwareco.com” is a fictional domain. The subdomain was identical but the domain is fictional.

Custom Grub Script for Dual Booting Ubuntu 9.10 and Windows XP

Linux No Comments

Most of the work I do with Ubuntu Linux is on home computers where the user needs to have Windows XP (Vista, 7) as a boot option. The best way for Ubuntu, or Linux in general, to work is if its on its own partition and not installed with the Wubi Installer. One of the main issues I have with installing Ubuntu on its own partition is that the Grub2 Boot Loader menu looks terrible and is confusing once you’ve gone through several kernels updates. I wanted a simple and easier to understand Grub2 menu and something that would take care of itself in the long run.

This script makes four entries at the top of the Grub2 boot menu.


Ubuntu
Windows

Other boot options:

The one titled “Ubuntu” should be the same as your first Ubuntu option and most updated kernel. The “Windows” is the first option returned by “/etc/grub.d/30_os-prober”. Which should return a bootable Windows Partition. This still leaves all the original boot options underneath so you can still take advantage of selecting an older kernel or the recovery mode. It will also include any Windows Recovery partitions as well towards the very bottom.

Disclaimer: I have no idea what this will actually do out in the wild. I surely can’t account for every scenario but I’ve done MY best and tested with a couple of systems with success!

Note: Do not use this if you are doing more than just dual booting Ubuntu and Windows!

Here is what my partition tables look like on the computer I tested with today. The script worked perfectly on it. As well as another Windows 7 machine I tested on.

/etc/grub.d/05_custom :


#!/bin/bash

awk '/BEGIN\ \/etc\/grub\.d\/10_linux/,/END\ \/etc\/grub\.d\/10_linux/' /boot/grub/grub.cfg > /tmp/grub1.tmp
LINE1=`grep menuentry /tmp/grub1.tmp -n | cut -f1 -d: | head -n1`
LINE2=`grep } /tmp/grub1.tmp -x -n | cut -f1 -d: | head -n1`
echo 'menuentry "Ubuntu" {'
sed -n "${LINE1},${LINE2}p" /tmp/grub1.tmp | sed -n "2,${LINE2}p"

#check for NTFS partitions!
#This also means this script is only for XP, Vista, or Win 7. (Not tested with Vista and Win7 yet!)
chkntfs=`sfdisk -l 2> /dev/null | grep NTFS -n | cut -f1 -d:`

if [ -n "$chkntfs" ]; then 
#grub-mkconfig 2> /dev/null | awk '/BEGIN\ \/etc\/grub\.d\/30_os-prober/,/END\ \/etc\/grub\.d\/30_os-prober/' > /tmp/grub2.tmp
awk '/BEGIN\ \/etc\/grub\.d\/30_os-prober/,/END\ \/etc\/grub\.d\/30_os-prober/' /boot/grub/grub.cfg > /tmp/grub2.tmp
LINE1=`grep menuentry /tmp/grub2.tmp -n | cut -f1 -d: | head -n1`
LINE2=`grep } /tmp/grub2.tmp -x -n | cut -f1 -d: | head -n1`
echo 'menuentry "Windows" {'
sed -n "${LINE1},${LINE2}p" /tmp/grub2.tmp | sed -n "2,${LINE2}p"
else
echo "There were no NTFS partitions found!" >&2
fi

#entries must point somewhere or they don't show up.
#might as well be the partition that houses our kernel. 
#also, when its selected it just shows the menu again.
#which makes it a nice dummy file.

echo "menuentry \\" \\" {"
echo "	insmod ext2"
echo `cat /tmp/grub1.tmp | grep "set root" | head -n1`
echo "}"

echo "menuentry \\"Other boot options:\\" {"
echo "	insmod ext2"
echo `cat /tmp/grub1.tmp | grep "set root" | head -n1`
echo "}"

To create the file and mark it executable… Open Terminal (Applications > Accessories > Terminal)


sudo gedit /etc/grub.d/05_custom
*** PASTE THE ABOVE SCRIPT AND HIT SAVE ***
sudo chmod +x /etc/grub.d/05_custom
sudo update-grub

End result:

At this point you could make Windows default by editing /etc/default/grub and chaning the line:


GRUB_DEFAULT="Windows"

I welcome any and all suggestions on how to improve this script. I make no claim to be very good at BASH scripting but I needed this and couldn’t find any other solutions!

Favorite Wallpapers for Ubuntu

Uncategorized No Comments

Here are two of my favorite wallpapers for Ubuntu. I like to go Distro themed when I work on computers by default.

karmic-rusty-2

Originally from Atkarus Designs.

Ubuntu 9.10 Wubi Install Grub2 Problems

Uncategorized No Comments

Apparently there are still some bugs to work out with Ubuntu 9.10 RC. If you install with Wubi and update grub2 automatically rewrites the MBR which disables bootup to Windows but Ubuntu keeps working. Here is a temporary solution.

We need to fix the MBR for Windows. Since Ubuntu is the only Operating System we can now boot we need a way to fix it from inside of Ubuntu. ms-sys is an older package that is no longer available in the repo’s because of copyrights.

Visit http://packages.debian.org/etch/i386/ms-sys/download and download the package. Firefox should automatically ask you to open with GDebi Package Installer. Click Install Package and type in your password.

Next open up a terminal. Applications > Accessories > Terminal.


sudo ms-sys -w /dev/sda
[sudo] password for craig:
DOS/Windows NT master b oot record successfully written to /dev/sda

for a shorter way….


cd /tmp && wget -c http://ftp.us.debian.org/debian/pool/main/m/ms-sys/ms-sys_2.1.0-1_i386.deb && sudo dpkg -i ms-sys_2.1.0-1_i386.deb && sudo ms-sys -w /dev/sda

All the above assumes you only have one hard drive in your system on /dev/sda. If you have more than one hard drive please check by using “sudo sfdisk -l”. You’ll be looking for something like:


Device       Boot Start End     #cyls   #blocks      Id  System
/dev/sdb1   *      0+   2549    2550-  20482843+  7  HPFS/NTFS

This tells us we have a NTFS partition on /dev/sda1 which is the first partition on /dev/sda. So we know that we need to use /dev/sda. Substitute for your own hard drive. That may be /dev/sdb or /dev/sdc. Of course if your using Wubi its probably safe to say /dev/sda.

« Previous Entries Next Entries »