Jump to content

Why use batch scripts?


excid3

Recommended Posts

Ok...so ive ended up just converting code from a couple of different payloads to see how this is going to turn out. It hardly does anything at the moment. I am able to do the exact same things as any other payload, probably simpler too. Unfortunately I am having to use a couple of plugins to make it simpler. They extract to the temp folder in Docs & Settings for the current user. Just thought I would leave an update, i'll post a link to download the payload once I decide on a few things....such as how I want the settings to work. Here's a bit of code from the main section of my nsis script to tide you guys over:

Section "Main"

 ;CreateDirectory "$EXEDIRlogs$%computername%"
  SetOutPath "$EXEDIRlogs$%computername%"

;=== Find the INI file, if there is one
        IfFileExists "$EXEDIRsettings.ini" "" NoINI

    ReadINI:
    ;=== Read the parameters from the INI file
        ReadINIStr $0 "$EXEDIRsettings.ini" "${NAME}" "SAFETYFILE"
        StrCpy "$SAFETYFILE" "$0"
        IfFileExists "$SAFETYFILE" TheEnd ""
    
   ;Read in the rest of the INI file 
    ReadINIStr $0 "$EXEDIRsettings.ini" "${NAME}" "BIN"
    StrCpy "$BIN" "$0"
     
    NoINI:
   ;TODO: SETUP DEFAULT VALUES

 ;If log file already exists, backup previous one and continue
  IfFileExists "$%computername%.log" "" Continue 
    CreateDirectory "$OUTDIRBackup"
      StrCpy $R0 "$OUTDIR"  ;Directory move from
      StrCpy $R1 "$OUTDIRBackup" ;Directory move into
      StrCpy $R2 0
      StrCpy $R3 0
      ${Locate} "$R0" "/L=F" "Move"
      IfErrors 0 +2
     ;MessageBox MB_OK 'error' IDOK +4
      StrCmp $R3 0 0 +2
     ;MessageBox MB_OK '$R2 files were moved' IDOK +2
     ;MessageBox MB_OK '$R2 files were moved$n$R3 files were NOT moved'
      delete "$OUTDIR$%computername%.log"

  Continue:
 ;LOCAL TIME
  ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
  StrCmp $4 0 0 +3
    StrCpy $4 12
    goto +3
    StrCmp $4 12 +5
    IntCmp $4 12 0 0 +3
    StrCpy $7 AM
    goto +3
    IntOp $4 $4 - 12
    StrCpy $7 PM
  nsislog::log "$%computername%.log" 'Date=$0/$1/$2 ($3)$nTime=$4:$5:$6 $7'

 ;COMPUTER NAME
  nsislog::log "$%computername%.log" "Computer Name: $%computername%"

 ;USERNAME + ACCOUNT INFO
  UserInfo::GetName
    IfErrors Win9x
    Pop $0
    UserInfo::GetAccountType
    Pop $1
    UserInfo::GetOriginalAccountType
    Pop $2
    nsislog::log "$%computername%.log" "Current User: $0"
    StrCmp $1 "Admin" 0 +3
        nsislog::log "$%computername%.log" 'User group: Administrators$nOriginal non-restricted account type: $2'
        Goto done
    StrCmp $1 "Power" 0 +3
        nsislog::log "$%computername%.log" 'User group: Power Users$nOriginal non-restricted account type: $2'
        Goto done
    StrCmp $1 "User" 0 +3
        nsislog::log "$%computername%.log" 'User group: regular user$nOriginal non-restricted account type: $2'
        Goto done
    StrCmp $1 "Guest" 0 +3
        nsislog::log "$%computername%.log" 'User group: guest$nOriginal non-restricted account type: $2'
        Goto done
    nsislog::log "$%computername%.log" "Unable to get Username and Account Type."
    Goto done
    Win9x:
        nsislog::log "$%computername%.log" "Error! Not compatible with Windows 9x!"
    done: 

 ;Save IPCONFIG /all to ipconfig.log
  ExecCmd::exec '"$SYSDIRipconfig.exe" /all >ipconfig.log' ""

    TheEnd:
SectionEnd

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...