Wednesday, July 15, 2015

Monitor active time of a process in windows OS

I wrote a simple script that will run on any windows operating system silently, then log if the specified application is running (eg. notepad.exe), if it is not running it will not update the log and the reason is to avoid large generated log file.

<<< logger.bat >>>
@echo off

set processname=notepad.exe                    
set MYPATH=c:\a
set LOGFILE=%processname%_%date:~4,2%%date:~7,2%%date:~10,4%.log
set PATHLOG=%MYPATH%\%LOGFILE%
set _my_datetime=%date%_%time%


echo %_my_datetime%, Searching for %processname%... >> %PATHLOG%
:loop
set _my_datetime=%date%_%time%
for /f "tokens=1 delims=," %%a in ('tasklist /fo csv ^|FINDSTR /I /C:"%processname%"') do call :searchprocess %%a
ping -n 6 127.0.0.1>NUL
goto :loop


:searchprocess   
echo %_my_datetime%, %success% >>  %PATHLOG%&goto :eof

<<< monitor_notepad.vbs >>

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "c:\a\logger.bat" & Chr(34), 0
Set WshShell = Nothing


You just have to create shortcut to startup folder.


Thursday, January 8, 2015

How to install OPENVPN

yum -y install wget wget http://swupdate.openvpn.org/as/openvpn-as-2.0.10-CentOS6.x86_64.rpm rpm -ivh openvpn-as-2.0.10-CentOS6.x86_64.rpm (i = Install, v = verbose, h = hash ) ovpn-init /usr/local/openvpn_as/bin/ovpn-init /usr/local/openvpn_as/bin/ovpn-init --force passwd openvpn passwd it adduser it passwd it GO TO IE https://:943/admin Login as "openvpn" with the same password used to authenticate to this UNIX host. During normal operation, OpenVPN AS can be accessed via these URLs: Admin UI: https://:943/admin Client UI: https://:943/

Monday, January 5, 2015

Morning Check Script

SPmorning_check.sh /opt/scripts (#1011) pwd /opt/scripts /opt/scripts (#1012) cat SPmorning_check.sh #!/bin/bash # #Morning checkout script - Check all processes are running # CONFIG="/opt/scripts/config/SPproc.conf" DISK_CHECK="/opt/scripts/sub/disk_check.sh" ############################################################################################# ############################### FUNCTIONS ################################################## ############################################################################################# #for i in `cat proc.conf | awk -F\| '{print $2}'`; do echo -n "$i "; ping -c2 "$i" &>/dev/null && echo success || echo fail; done foo () { yes '' | head -n2 #Echo several blank line echo "Ping Test Results" for i in `cat $CONFIG | egrep -v "^#|^;"`; do network=`echo $i|awk -F\| '{print $3}'` if [ "$network" = "$1" ] then ip=`echo $i|awk -F\| '{print $2}'` ping -c1 "$ip" &>/dev/null && echo -n "[ OK ] " || echo -n "[ CRITICAL ] " echo $i | awk -F\| '{print "\t \t" $2 "\t" $1}' fi done yes '' | head -n3 #Echo several blank line } ############################################################################################# ############################### FUNCTIONS ################################################## ############################################################################################# echo " ###################################################" echo " WIRELESS NETWORK in GTP Availability" echo " ###################################################" foo 'AP' echo " ###################################################" echo " Internet Service Provider Availability" echo " ###################################################" foo 'ISP' echo " ###################################################" echo " Check Browsing" echo " ###################################################" foo 'WEB' echo " ###################################################" echo " GTP Managed Servers Availability" echo " ###################################################" foo 'MS' echo " ###################################################" echo " Cloud Servers Availability" echo " ###################################################" echo " DIGITAL OCEAN" foo 'DIGITALOCEAN' echo " RACKSPACE" foo 'RACKSPACE' echo " ###################################################" echo " Disk Space Check" echo " ###################################################" $DISK_CHECK ops.stratpoint.com $DISK_CHECK gw1 /opt/scripts/sub (#1025) pwd; cat disk_check.sh /opt/scripts/sub #!/bin/bash HOSTS=$1 LOCAL_HOST=`hostname -s` disk_thresh="80" # Function which displays threshold check results # function threshold { percentage="$1" stringlen="$2" outputval="" while [ $stringlen -lt 20 ] do outputval=$outputval" " let stringlen++ if [ $stringlen -gt 19 ] then if [ $percentage -gt $disk_thresh ] then outputval=$outputval"CRITICAL" else outputval=$outputval"OK" fi fi done echo "$outputval" } for host in $HOSTS; do hostname=$host if [ "$hostname" == "$LOCAL_HOST" ] then sshreq=`hostname | cut -f1,2,3 -d.; df -h` else sshreq=`ssh -24aqx -o 'BatchMode yes' $hostname "hostname | cut -f1,2,3 -d.; df -h " 2>/dev/null` fi hostline=`echo "$sshreq" | head -1` headers=`echo "$sshreq" | head -2 | tail -1 | awk '{ print $5"\t"$4"\t"$2"\t"$6}'` diskstatus=`echo "$sshreq" | tail -n+3 | awk '{ print $5"\t"$4"\t"$2"\t"$6}'` echo -e "Hostname: $hostline" echo -e "-------------------------------------------------\n" echo -e "$headers\n" echo "$diskstatus" | while read x; do percentageval=`echo "$x" | awk -F '%' '{print $1}'` echo -n "$x" padlength=`echo $x | awk '{print $4}'` threshold "$percentageval" "${#padlength}" done echo -en "\n\n" done /opt/scripts/config (#1029) pwd; cat SPproc.conf /opt/scripts/config SPwf1|192.168.1.10|AP

Monday, July 14, 2014

Linux commands

for F in `cat hosts`; do echo "::$F::";ssh -q -o "ConnectTimeout=2" $F 'hostname -s'; ssh -q -o "ConnectTimeout=2" $F '/sbin/ifconfig'|perl -ne '$eth=$1 if(/^(\S+)\s+Link en/); if(/inet addr:(\S+)/){print "$eth: $1\n"}'; done | tee /tmp/allips


/usr/sbin/ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== 142.201.48.241 142.201.48.242 4 u 833 1024 377 0.321 -0.132 0.206 *142.201.48.242 132.246.11.229 3 u 291 1024 377 0.973 -0.248 0.047


alias grep='grep --color=auto'
alias egrep='egrep --color=auto'


egrep "^[[:cntrl:]]" xlif.sym


grep -E "\S+*\.AT" bb.sym #42 Holy Rosary St

################################# script #################################

#!/bin/bash

#

# Script to test ssh login via ssh keys

#

 

 

HOSTS="$(cat $1 | grep -v ^# | grep -v ^$ | cut -d: -f1)"

 

for host in $HOSTS;

do

 

hostname=$host

CURRENT_DATE=`date +%s`

REMOTE_DATE=`ssh -oConnectTimeout\=5 -oPasswordAuthentication\=no $hostname "date +%s" 2&gt; /dev/null`

 

diff=$((REMOTE_DATE - CURRENT_DATE))

if [ "$REMOTE_DATE" = "" ]

then

echo "$hostname: !!! FAILURE !!!"

else

echo "$hostname: Success : ssh start time: $CURRENT_DATE end time: $REMOTE_DATE diff = $(($diff / 60)) mins $(($diff % 60)) secs"

 

fi

 

done

################################# script #################################

Tuesday, October 11, 2011

Task Manager forcing endtask running process

Here some tips using batch line.

If the virus is running in your computer find the virus name first.
If you found it

type in the command line

taskkill /IM virusname.exe /F the IM and F should be capitalize.

This command will kill or stop the virus from running in your computer.

The next thing you do is to delete all virus but first you must find the path where the virus is located.

If you found it go to the virus path using cd command. For example the virus is in system32

you must type this "cd windows\system32"

then the prompt will be in system32 and it will look like this c:\windows\system32>_

then type attrib -r -h -s virusname.exe

this command will make the virus visible.

so type then erase or del virusname.exe

Thats it...

Sorry for my bad english.. lolz

Friday, February 25, 2011

How to unhide files That’s been Hidden by a Virus in USB Flash Drives or hard disks

How to unhide files That’s been Hidden by a Virus in USB Flash Drives or hard disks

Nowadays, floppy drives are just remnants of old computers. Majority of computer users today are using USB Flash Disks as their primary storage of their files. Goodbye to the 1.4mb diskettes. You don’t have to buy lots of these diskettes just to store large files anymore.

With USB Flash drives, all you need is a computer that has USB port to plug in to which is available in every computer today. Not only they are handy because of their small sizes, USB Flash drives can also store large files!

The problem with using these flash drives, they’re easily infected with viruses. Some forms of virus infections among flash drives are the following: hides your files and folders, creates exe file extensions of your files and even corrupt your files. And later on infecting your PC.

If you have a strong antivirus, you don’t have to worry with these threats that could infect your computer when a USB flash drive has been plug to the computer because they are easily deleted upon detection.

Now, if your files have been infected even your antivirus is up-to-date and they’ve been hidden and no longer visible when you open your files, these are some tips on how to unhide hidden files caused by a virus.

1. Sometimes this infection can be solved by:

* Going to Windows Explorer
* Tools menu
* Folder Option
* View Tab
* Choose “show Hidden Files and Folders”.
* If the files will show up, simply change the properties of the files/folders. Uncheck the “hidden” checkbox and the files will show again just like before.

2. If the above doesn’t work, and your files are still hidden, do this one that will surely work.

* Go to the command prompt.
* Go to the drive where your hidden files are located.
* Type the following: attrib -s -h /s /d *.* (this will unhide all your files that have been hidden by the virus) i.e. I:\> attrib -s -h /s /d *.*

There you go, a quick and easy way on how to unhide hidden files caused by a virus in your computer.