Elevated & Remote Commands

email me

Combining Cpau and Psexec can prove to be quite a powerful combination.

This is how you would launch a process in elevated security…and also remotely launch a file.

CPAU
Use cpau.exe to change the security context and launch the local script. Note, I also pass the PC name to the remote.cmd using strComputer1

objShell.Run “%comspec% /c cpau.exe -u %computername%\administrator -p PASSWORD_HERE -ex “”remote.cmd ” & strComputer1 & chr(34) & ” -lwop -hide”,0,false

 

PSEXEC
The contents of the remote.cmd (how you launch a script remotely using psexec)

@echo off

if not “%1” == [] set PC=%1
if “%1” == [] exit /b 0

rem sets PC name – it was passed from the VBScript/HTA above
SET PC=%1

rem copies your script to the remote computer
copy /y script.cmd \\%PC%\c$\windows\system32
Menu\Programs\Startup\”

rem launches the script remotely
psexec \\%PC% /accepteula -d -s script.cmd

How to Copy a Textfile to the Clipboard

email me

If WScript.Arguments.Count Then
Const FOR_READING    = 1
Const MAX_CHARACTERS = 8192
Set fs = WScript.CreateObject(“Scripting.FileSystemObject”)
Set f  = fs.OpenTextFile(WScript.Arguments(0), FOR_READING)
t = f.Read(MAX_CHARACTERS)
With WScript.CreateObject(“InternetExplorer.Application”)
.Navigate “about :blank”
Do Until .ReadyState = 4 : WScript.Sleep 50 : Loop
.document.ParentWindow.ClipboardData.SetData “text”, t
End With
f.Close
End If

Perform these steps to implement the script in the txtfile’s right-click context menu:

•Save the code as C:\WINDOWS\system32\Cop2Clip.vbs
•Start regedit.exe and expland the HKCR\txtfile key in the left pane
•Right-click HKCR\txtfile\shell and create a new key called Cop2Clip
•Mark HKCR\txtfile\shell\Cop2Clip and double-click the (Default)-entry in the right pane.
•Enter “C&opy file contents to clipboard” – this text will appear in the context menu.
•Right-click HKCR\txtfile\shell\Cop2Clip and create a new key called command
•Mark HKCR\txtfile\shell\Cop2Clip\command and double-click the (Default)-entry in the right pane.
•Enter C:\WINDOWS\system32\wscript.exe C:\WINDOWS\system32\Cop2Clip.vbs //nologo “%1″ – this is the command line that will be executed if you choose the new Copy file contents to clipboard context menu item.

Script to copy last 10 lines from text file

email me

VBScript

Const FOR_READING = 1

Dim objFs, objFile, strFileName, LinesToReturn, i, aryLine, j

strFileName = “test.txt”
LinesToReturn = “10”
Set objFs = WScript.CreateObject(“Scripting.FileSystemObject”)
If objFs.FileExists(strFileName) Then
Set objFile = objFs.OpenTextFile(strFileName, FOR_READING)
ReDim aryLine(LinesToReturn)
i = 0
Do Until objFile.AtEndOfStream
i = (i+1) Mod LinesToReturn
aryLine(i) = objFile.ReadLine
Loop
For j = 1 To LinesToReturn
If aryLine(j) = vbEmpty Then Exit For
WScript.Echo aryLine(j)
Next
End If

 

Batch

@echo off > NFILE & setLocal enableDELAYedeXpansioN

:main
for /f “tokens=1* delims=[]” %%a in (‘find /n /v “” ^< MFILE’) do (
set LAST=%%a
)

set/a FIRST=LAST-9

for /f “tokens=1* delims=[]” %%a in (‘find /n /v “” ^< MFile’) do ( if %%a geq !FIRST! echo.%%b ) >> NFILE
goto :eof

Java 7 Update 67 Release Highlights

email me

Java 7 Update 67 (7u67)

Release Highlights
  • IANA Data 2014c
    JDK 7u67 contains IANA time zone data version 2014c. For more information, refer to Timezone Data Versions in the JRE Software.
  • Bug Fix: regression – java_arguments not accepted after update to 7u65
    The regression is addressed in this release. See 8050875.
Java Expiration Date

The expiration date for 7u67 is October 14, 2014. Java expires whenever a new release with security vulnerability fixes becomes available. For systems unable to reach the Oracle Servers, a secondary mechanism expires this JRE (version 7u67) on November 15, 2014. After either condition is met (new release becoming available or expiration date reached), Java will provide additional warnings and reminders to users to update to the newer version.

» 7u67 Release notes

Networking Equations

email me

  • Propagation delay = distance traveled / propagation speed
  • Transmission delay = # of bytes to transfer / transmission speed (or bandwidth)
  • Signal-to-noise ratio (dB)  = 10 log10 (S/N)
  • Attenuation in decibels = 10 log10 (Transmitted power/received power)
  • Nyquist Theorem : Maximum data rate = 2 H log2V bits/sec   where H is in Hz and V is # of levels
  • Shannon’s Result : Maximum number of bits/sec = H log2 (1+S/N)    where H is in Hz

 

  • Pure ALOHA  throughput          T = Ge-2G      Max throughput occurs at G = 0.5

T = throughput per frame time           e = 2.718

G = attempts per packet time

Throughput in bits per sec = T x transmission speed

Vulnerable period = 2 x frame transmission time

 

  • Slotted ALOHA throughput      T=Ge-G    Max throughput occurs at G = 1
  • TCP round-trip time

RTT = α RTTOLD + M(1 – α)                               RTTOLD = previously observed round-trip time

α = smoothing factor
M = observed round-trip time (actual time to receive an ACK)

D = βDOLD + (1 – β) · |RTT – M|                         DOLD = previously observed standard deviation

β = smoothing factor (may be α)
TCP Timeout = RTT + 4D

 

  • Ethernet / IEEE 802.3  (p. 280)

Channel efficiency = t / (t + 2G/A)

t = ave time to transmit a frame

G = end-to-end propagation time (time for frame to traverse entire Ethernet network)
2G = duration of each time slot

A = probability that some station acquires channel in a particular contention slot

= kP(1 – P)k-1

k = # of stations ready to transmit

P = probability that each station transmits during a contention slot

Channel efficiency = 1/(1 + 2BLe/cF)

B = network bandwidth                                       c = signal propagation speed

L = cable length                                                    F = frame length

e = contention slots per frame (2.718)

Maximum throughput = channel efficiency x transmission speed

Minimum frame length = 2 x propagation delay x transmission speed (data rate)
* 802.3 minimum frame length = 64 bytes

Check Internet Connection in HTA via Ping

email me

‘Check Internet Connection
on error resume next
strURL = “www.google.com”
ConnectionTest = WSHShell.Run(“cmd /c ping -n 2 ” & strURL, 0, True)
‘If ConnectionTest = 0 then msgbox “You are connected!”
If ConnectionTest = 1 then
msgbox “This computer is not connected to the network. Please check your connection and try again.”
location.reload()
end if

* remember to instantiate the WSHShell.Run object…