Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to get the parameters that passed to a specific function.
for example:
load("return 2+1")()
wanted output:
return 2+1
I have no idea after reading debug library :(
If I correctly understand what you want, override the load function prior to calling it:
local global_load = load
local function load (...)
print (...) -- or use whatever debug tool to see the arguments.
return global_load (...)
end
You can redefine any function this way:
local function verbose (func)
return function (...)
print (...) -- or use whatever debug tool to see the arguments.
return func (...)
end
end
local load = verbose (load)
print (load 'return 2 + 1' ())
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
ADDRESS=0.0.0.0
CACHE_SIZE_MB=32
CORS_ENABLED=true
CORS_ALLOWED_HEADERS=
CORS_ALLOWED_METHODS=
CORS_ALLOWED_ORIGINS=
CORS_ALLOW_CREDENTIALS=
CORS_DEBUG=true
HOST_ONLY_DOMAINS=*
HTTP_CLIENT_TIMEOUT=5s
HTTP_MAX_AGE_DURATION=720h
HTTP_USER_AGENT=''
POPULAR_SITES=bing.com,github.com,instagram.com,reddit.com
PORT=8080
SERVER_MODE=redirect
I have this docker_run file. From the Go server how to properly set up this file?
I have an example.com where the server hosted and I am trying to use this API to my example1.com.
I have this docker_run file. From the Go server how to properly set up this file?
This file has nothing to do with Go. I guess it was supposed to be read by the application and applied there.
If you have an instance of http.HandlerFunc you can warp it into a new function call in the following way:
func setCors(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "your origin value...")
w.Header().Set("Access-Control-Allow-Methods", "your methods...")
w.Header().Set("Access-Control-Allow-Headers", "your headers...")
w.Header().Set("Access-Control-Max-Age", "your age...")
// other settings
h(w, r)
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a(nother) string of lua code that's obfuscated. I'm wondering if it's possible to deobfuscate it, or to figure out how it was obfuscated, as I've never encountered anything like it before. This string of code is supposedly the main module for a malicious serverside script executor. Knowing what's inside will help us patch the exploit on our platform. I'm told that it would be easy to decipher by getting the constants, because it's VM based obfuscation, we just need a bit of help getting pointed in the right direction.
The code is rather large, so it's in this pastebin.
pastebin com/dtfzBPZk
Deobfuscating this one looks like it will be a slightly more manual process. As usual, the first things you should do are rename variables to have saner names, and add whitespace and indentation to the code. You can see a start to this at https://pastebin.com/eRTGAbTH. Once you do that, you'll see a pattern of functions like this:
(function(...)
local SynapseXen_116 = "hi xen doesn't work on sk8r please help"
local SynapseXen_092 = SynapseXen_100(38909278, 3932326132)
local SynapseXen_069 = {...}
for SynapseXen_109, SynapseXen_043 in pairs(
SynapseXen_069
) do
local SynapseXen_119
local SynapseXen_097 = type(SynapseXen_043)
if SynapseXen_097 == "number" then
SynapseXen_119 = SynapseXen_043
elseif SynapseXen_097 == "string" then
SynapseXen_119 = SynapseXen_043:len()
elseif SynapseXen_097 == "table" then
SynapseXen_119 = SynapseXen_100(4264903821, 30110892)
end
SynapseXen_092 = SynapseXen_092 + SynapseXen_119
end
SynapseXen_140[1171393165] =
SynapseXen_bit_bxor(
SynapseXen_bit_bxor(2179831066, SynapseXen_092),
SynapseXen_bit_bxor(2132161653, SynapseXen_082)
) -
string.len(SynapseXen_116) -
SynapseXen_139 -
#{
2716917292,
2960928816,
2092744992,
3945961999,
2156388474,
2523828292,
534526172
}
return SynapseXen_140[1171393165]
end)({}, {}, 14275, 107, "iIIllIIlIIilillilI", "i", 5327, 3211, 14382, 14643)
Now you can start to eliminate red herrings. For example, any time you see #{ a bunch of stuff in here }, you can just count the elements in the list, and replace the whole thing with the count. In this case, there's one of those near the end we can replace with the number 7. Next, look at SynapseXen_116. The only place it's used is for its length, so you can substitute that in as well. Now, After that, notice that this is declaring a function and then immediately invoking it, so you can substitute in its arguments. Continue going down that path until you uncover the heart of the Lua-in-Lua VM, and from there, it should be easy to plug in the Base64 at the end, and see what bytecode it decodes to.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is it possible to write such a line, and within this line I want change a variable value?
opacity: condition == true ? 1, stringName ='Steve' : 0
Not sure what you expect the code to do exactly but my guess
opacity: condition == true ? (){ stringName = 'Steve'; return 0; }() : 0;
You can't have a list of expressions in the true or false part, only one single expression.
I think this is what you wanted
opacity : condition== true ? 1 : stringName == "Steve" ? 0 : 2,
I am not sure you will be able to achieve the best result in a case like this using ternary expressions. Instead, you can create a sperate function that you can bundle in all your conditions and maybe return an appropriate variable as the case may be.
After the you can call the SetState() Function to update your widget.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a method that I can to push to a JSON call. The function looks like:
def my_function(name, text , id_person, id_company)
end
What I want is to get:
{"my_function":{"name":"names_value","text":"text_value ","id_person":"id_person_value","id_company":"id_company_value"}
Is there any easy way to do this?
The question is a bit unclear, but let me try with few answer possibilities
First of all this is not a JSON format
{"my_function":{"name":"names_value","text":"text_value ","id_person":"id_person_value","id_company":"id_company_value"}
There should not be double quote (") before semicolon (:)
obj = {
my_function:
{
name: "names_value",
text: "text_value",
id_person: "id_person_value",
id_company: "id_company_value"
}
}
If you want to get each of the data in that "JSON" format, you could do this
name = obj['my_function']['name'] #name_value
text = obj['my_function']['text'] #text_value
and so on...
But if you want to make a string data into JSON format, you could do this
def my_function(name_value, text_value, id_person_value, id_company_value)
{
my_function:
{
name: name_value,
text: text_value,
id_person: id_person_value,
id_company: id_company_value
}
}.to_json
end
I hope it's answering your question...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I'm having problems when I'm trying to put a condition in params in my controller. This code is inside my controller:
if params[:example] == 1
#table = Model.find(:all,:conditions=>['column_table= ?',params[:example] ] )
else
#table = Model.find(:all,:conditions=>['column_table2= ?',params[:example] ] )
end
Is this code correct? How can I put a conditional in params controller?
You code looks okay. Unfortunately you do not say what problem you have. The only thing I see that may fail is the condition. If you pass some value into your params they are not typecasted. Therefore I guess you should use to_i in your condition:
if params[:example].to_i == 1
...
Try with
#table = Model.where((params[:example] == 1 ? 'column_table= ?' : 'column_table2 = ?'), params[:example]) unless params[:example].blank?
Here is code. You have save params[:example] in one variable.and use your coditions.
if params[:example].present?
#example = params[:example]
if #example == 1
#table = Model.find(:all,:conditions=>['column_table= ?',params[:example] ] )
else
#table = Model.find(:all,:conditions=>['column_table2= ?',params[:example] ] )
end
You can also send the column name along with its value and avoid ifs
#table = Model.find(:all,:conditions=>["#{params[:col]} = ?", params[:example] ] )