Monthly Archives: June 2009

Install UltraVNC msi remotely using a VBS / VBScript

Hi,

To create a silent MSI for UltraVNC I have used this open source app that you can get it here: UltraVNC MSI Creator

To create the MSI just follow the instructions is plain and simple.

Now the script so you can remotly install on any PC you got administrative privileges:

 Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = InputBox("Writte down the target computer","UltraVNC Remote INSTALL","Nomed do Computador", 50, 50)
Const UVNCPath = "\\yourultravncpath\UltraVNC.msi"
Const Overwrite = True
wsLocation = "\\" & strComputer & "\c$\Windows\Temp\"

if strComputer = "" then
	WScript.Quit
end if

if Ping(strComputer) then
	objFSO.CopyFile UVNCPath, wsLocation ,Overwrite
else
	msgbox("Can't reach the target computer, sorry!")
	WScript.Quit
end if

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objSoftware = objWMIService.Get("Win32_Product")
errReturn = objSoftware.Install("C:\Windows\Temp\ultravnc.msi",,True)

if errReturn = 0 then
	msgbox("Yupii, installed with success.")
	else
	msgbox("Can't install, sorry!")
end if

Function Ping(PC)
	Set objWshScriptExec = objShell.Exec("C:\WINDOWS\system32\ping.exe " & PC)
	Set objStdOut = objWshScriptExec.StdOut

	awake=False
	Do Until objStdOut.AtEndOfStream
		strLine = objStdOut.ReadLine
		awake = awake Or InStr(LCase(strLine), "bytes=") > 0
	Loop
	Ping = awake
End Function

Install mrtg to monitor Squid proxy cache – CentOS

This is how I configure MRTG to monitor cache and web access from squid.

First you need to install mrtg, lucky for us CentOS 5.3 already have it in reps, so just need to run:

yum install mrtg

Then configure your squid.conf to allow snmp, put this lines on your squid.conf file:

snmp_port 3401
acl snmppublic snmp_community public
snmp_access allow snmppublic all

Next copy mib configuration files from squid to mrtg directory:

cp /etc/squid/mib.txt  /etc/mrtg/squid.mib

Now edit /etc/mrtg/mrtg.cfg file, and add this lines in the end, and change yourserverhost:

LoadMIBS: /etc/mrtg/squid.mib
Target[proxy-hit]: cacheHttpHits&cacheServerRequests:public@yourserverhost:3401
# If you are using Squid 2.6 or later, uncomment the following line
#RouterName[proxy-hit]: cacheUniqName
MaxBytes[proxy-hit]: 100000
Title[proxy-hit]: HTTP Hits
PageTop[proxy-hit]: 

proxy Cache Statistics: HTTP Hits/Requests

System:yourserverhost
Maintainer:The Master of Universe
Description:Squid Proxy server
Suppress[proxy-hit]: y LegendI[proxy-hit]: HTTP hits LegendO[proxy-hit]: HTTP requests Legend1[proxy-hit]: HTTP hits Legend2[proxy-hit]: HTTP requests YLegend[proxy-hit]: perminute ShortLegend[proxy-hit]: req/min Options[proxy-hit]: nopercent, perminute, dorelpercent, unknaszero Target[proxy-srvkbinout]: cacheServerInKb&cacheServerOutKb:public@yourserverhost:3401 # If you are using Squid 2.6 or later, uncomment the following line #RouterName[proxy-srvkbinout]: cacheUniqName MaxBytes[proxy-srvkbinout]: 76800 Title[proxy-srvkbinout]: Cache Server Traffic In/Out PageTop[proxy-srvkbinout]:

Cache Statistics: Server traffic volume (In/Out)

System:proxy.sg.private
Maintainer:Serassio Guido
Description:Squid Proxy server
Suppress[proxy-srvkbinout]: y LegendI[proxy-srvkbinout]: Traffic In LegendO[proxy-srvkbinout]: Traffic Out Legend1[proxy-srvkbinout]: Traffic In Legend2[proxy-srvkbinout]: Traffic Out YLegend[proxy-srvkbinout]: per minute ShortLegend[proxy-srvkbinout]: b/min kMG[proxy-srvkbinout]: k,M,G,T kilo[proxy-srvkbinout]: 1024 Options[proxy-srvkbinout]: nopercent, perminute, unknaszero

Edit your httpd mrtg to allow other hosts other that localhost:
edit the file: /etc/httpd/conf.d/mrtg.conf
configure like this to allow acess from anywhere:

Alias /mrtg /var/www/mrtg

    Allow from all

And finally crontab to update the data every 5 minutes:

crontab -e

in the end add this line:

*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

Reload Apache, cross fingers, and try to access http://yourserver/mrtg/proxy-hit.html

Reset / Repair linux permission

If you, like me did a chown -R…. or chmod -R…. out of the place you should done it and now your system is collapsing from the inside out, fear not, the solution is simple.

To set permissions of files in a package, enter:

rpm --setperms {packagename}

To set user/group ownership of files in a package, enter:

rpm --setugids {packagename}

And for what matter, the massive way, reset the entire file and group permission in the system:

for p in $(rpm -qa); do rpm --setperms $p; done
for p in $(rpm -qa); do rpm --setugids $p; done

Just run both and u’ll be back in business @ no time!

source

Find biggest objects in Squid-Cache

Just go to your log directory, normaly /var/log/squid and run the command:

sort -r -n +4 -5 access.log | awk '{print $5, $7}' | head -25

Purge / remove one site from Squid-Cache

To purge some site from your cache first ensure that in your squid.conf you are allowing purge, for example:

#Create ACL
acl purge method PURGE

#Aply ACL Rules
http_access allow purge localhost
http_access deny purge

After adding this lines don’t forget to run:

squid -k reconfigure

and the to remove site from cache just run the following command:

squidclient -m PURGE https://twitter.com

Tail for windows

Here is a great tools to follow those txt log files that you may find on windows

The download page is: tailforwin32

Some files that could be usefull to check with tail:

c:\WINDOWS\WindowsUpdate.log

Follow this one to know, for example, if your computer is connected to a WSUS server for updates

C:\Program Files\Exchsrvr\yourservername.log\*.log

This one is useful since exchange server does not provide a useful (at least that i’m aware) way to check in real time incoming mails.

Increase shell history lines

Just run the following command and u will get 1000 lines of history:

echo "HISTSIZE=1000" >> ~/.bashrc

DNS global propagation

Here is a fine tool that allow you to see DNS propagation over the world: http://www.whatsmydns.net/

Remote shutdown Windows from Linux

Just run the following command:

net rpc SHUTDOWN -C "enter a comment to display at shutdown" -f -I x.x.x.x -U username%password

where x.x.x.x is the ip address.

To know what machines are on in a particular subnet just nmap it, like this:

nmap -sP 192.168.5.0/24 | cut -d " " -f2 > lixo.txt

And with the lixo.txt you can cicle the computers and shut them down, just run this:

for i in $(cat lixo.txt);do net rpc SHUTDOWN  -f -I $i -U user%password; done

Centos 5.3 minimal services

I always disable most of the services witch are activated by a default Centos 5.3 instalation.

Read more »