im trying to make like a log, like: "User: X_Stack#0121 used command: /test at 18:21" or smth like that, but i dont know how to make this, like when user make this command: /test that in a txt file named "log.txt" one line is "User: X_Stack....." and in the second line is another command and a other time and a other user and over and over.
Sorry for my bad explination and my english.
Hopefully someone can help me ):
I readed alot of questions and answers here, but none of them helped me or answered my question.
Related
I'm writing some client side javascript code that we expect to be reverse engineered at some point. I want a way that we can say with a reasonable degree of certainty that we are not exposing any debug information. We are running the code through uglify, so it obfuscates the variable names.
My thought was to fetch all the string literals (and tokens?) from the file and match them using a jest snapshot, but I can't find a tool that will pull the information from the JS file. Does anyone have any experience doing this?
Update:
I think it would help if I gave an example
Suppose someone were to write this code:
function processSensitiveData () {
console.log('processing sensitive data')
doMoreThings();
}
processSensitiveData();
There is nothing wrong with that because we strip console.log statements in production, and uglify transforms the function name, so no sensitive information is present. Suppose someone were to modify it to this code:
function processData (dataType) {
console.log('processing ' + dataType + ' data');
doMoreThings();
}
processData('sensitive');
Now, while the console.log statement gets stripped out, 'sensitive' will still be in the final output. It's this kind of thing that we want to avoid. While code reviews are the first line of defense, this is very likely to be missed in a code review, especially if combined with other changes. I'd like to have the computer do it, as that is something that a computer would do much better than a human. Ideally, it would be a linting rule, but that would be a very complicated rule to write.
Code reviews. This way if you review any and all code checked into source you will be aware if there is debugging information that is trying to sneak its way into your repo. Besides that you can keyword search before deployment as well for 'alert', 'debug' and other debugging JavaScript keywords.
I came here to ask for your help because I'm a little lost in this challenge I have in hands along some days.
My goal is simple (although I do not know if it's easy to implement on code) - edit/modify the string "Password: " printed on Sudo (anything) command which is usually accompanied by a key symbol on right. My goal is not only modify the sting for another one but also in case of that possibility, replace for another symbols. Looking on Mac OS or iTerm terminals we can see clearly examples of what I'm describing typing "sudo whoami".
Looking on Hyper Open Source terminal to accomplish my objective I don't understand why am I unnable to edit that string on node_modules/getpass/lib/index.js - line 46 (for who has this terminal installed).
It is the only file on this program where the word is supposed to be printed. After modifying the word/string, nothing changed. Am I looking in the wrong place? Is it something more internal/deep to which I do not have access?
I hope you can elucidate me on the way forward. Thanks for your time!
Are you trying to change it in Hyper itself?
You're referencing the module node-getpass, its getPass function looks like this:
.getPass([options, ]callback)
if you pass an object with a prompt property you can set a custom prompt, instead of the text Password.
let options = {
prompt: "Type your password:"
}
const pass = require('getpass')
pass.getPass(options, callback);
I can't remember how long ago it was, but Discord.js updated in the time that I was away and not coding. One of the things that was updated and will be removed in 1.12 (or so I'm told) is the sendFile option. sendFile, senMessage, etc. are all under a single 'send' now. I haven't had any trouble with it till I went to go make a command where a user gets a file from an /images folder.
What I'm referring to. Any help would be appreciated. And it goes without saying, but I'm decently new to coding, along with the Discord.js lib.
I figured it out with the help of moi good ol' pall Matt.
The code looks around something like this if anyone else stumbles upon this.
message.channel.send("Testing message.", { files: ["./images/headpat1.png"] });
The file variable has to be an array even if you want to send one file. But because it is an array you can send multiples files. For exemple :
message.channel.send("Testing message.", {
files: [
"./images/headpat1.png",
"./images/headpat2.png"
]
});
You can read more about these properties, methods and paramters here
Discord.js - stable release - textChannel#send()
The sendFile method has been deprecated because they wanted to implement DataStore to increase efficiency of the API. You need to use send instead of sendFile to avoid errors in future.
/* File should wrapped in an array! */
message.channel.send({
files: ['./images/blackman-harris.png']
});
Other users, send an excessive text message with the file. It's optional to send a text along with with file. Further more information is available on the wiki page for send method.
I have a task in Gruntfile.js which can potentially wipe my project and I want to protect it with a "Are you sure you want to run this task?" question before running it, just to be safe. Something like:
grunt.registerTask('install', 'Run this only once when starting a project!', function() {
console.log('Are you sure? Y/n:');
// If yes, continue with task
grunt.task.run('copy_install');
});
But I don't know how to make it wait for keyboard input and read the input. Could not find this documented either.
Don't do it! You will regret this!
Grunt is a build tool and you grunt script should only be able to wipe what it created. No matter what the reasoning behind your current state is, change it. Use the tool for what is was meant to do, not for wiping stuff you dont want to lose.
Take a look at grunt-prompt or grunt-confirm.
I stumbled upon a bit of code that creates a popup, and you can edit the text from it, add multiple lines...
mshta javascript:alert("Line 1\n Line 2");close();
Go ahead and fire up command prompt and enter in that line. I guess that the \n means next line, as you can add/delete those all you want.
My question is, is there a way to use that same popup method, but rather than have a single button that says "OK", use two buttons, that when you click one, you "goto a", and when click the other, you "goto b".
I also can't figure out how to modify that other popup that I posted above, to say change it from "HTML APPLICATION" to some other title, and rename the "OK" button to something else. Either way, that is beside the point, and just curiosity kicking in.
EDIT: In my last comment, about closing the script, I figured out that I can just throw
;close();
at the end of the parentheses. But how can I set the true/false as a variable in the batch script?
EDIT: I have decided that autoit is a much better language for this kinda thing. Voting to have closed.
Ok, first let me explain what is going on in your example. When you type in:
mshta javascript:alert("Line 1\n Line 2");close();
what you're actually doing is telling your computer:
Run the program called mshta.exe, and pass the following javascript to it as an argument
You can do this with any program, for example, try opening notepad with a new file called "banana.txt" by typing:
notepad banana
Note that both cases have virtually nothing to do with batch. In your example, mshta.exe just runs some javascript to open an alert window, just as in my example notepad.exe deals with the creation of the .txt file.
Ok, so now that we've got that out of the way, onto your actual question: Is there a way to write a script in batch that will open a popup confirmation window?
The simple answer to your question is no. Batch is very good[citation needed] at moving around directories, opening files/programs, and...that's about it. If you need to do anything that isn't in that list, you should really be using a different scripting language.
However, while I cannot emphasize enough how much that is the correct answer to your question, I recognize that it's not a very satisfying one, so I will say that if you absolutely have to have a solution in batch, I would do something like the following:
#echo off
echo code=Msgbox("I'm A Message Box!", vbYesNo, "I'm The Title!") > "%temp%\popupBox.vbs"
echo WScript.Quit code >> "%temp%\popupBox.vbs"
cscript /nologo "%temp%\popupBox.vbs"
if %errorlevel%==6 call :ok_tag
if %errorlevel%==7 call :cancel_tag
echo Done!
exit /b 1
:ok_tag
echo You pressed Yes!
exit /b
:cancel_tag
echo You pressed No!
exit /b
This code essentially circumvents your problem by creating and running a temporary vbscript file (another scripting language) whose job is to display a confirmation window for you, and then using the exit code from that script to determine which button was clicked.
Notice again how much longer and more complicated this is than simply writing the program in pure vbscript to begin with, but if you must have a .bat file, then a .bat file you shall have.
#echo off
for /f "usebackq" %%f in (
`mshta "javascript:new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(new ActiveXObject('WScript.Shell').PopUp('Select one',0,'Title',36));close();"`
) do (
if "%%f"=="6" (
echo YES
) else if "%%f"=="7" (
echo NO
) else (
echo ????
)
)