How to know character code when texts in a log file are written - character-codes

Below is in the log file.
> [32m??????[00m
> [33m?≪?SDH?梧昭絽檎?????祉???儀??賢?с???[00m
I want a spedific command run. The command send EDI data from application server to EDI base server.
Some sort of error occured so I opened a log file.
How can I know what kind of character code when these texts are written ?

Related

Execute Bash Script within a PDF File

I recently discovered that concatenating text to the end of a PDF file does not change properties of the PDF file. This may be a very silly question, but if a program were concatenated to the PDF file, could it somehow be executed?
For example, opening this PDF file would create a text file in the home directory with the words "hello world" in it.
*pdf contents*...
trailer^M
<</Size 219/Root 186 0 R/Info 177 0 R/ID[<5990BFFB4DF3DB26CE6A92829BB5C41B> <B35E036CA0E7BA4CBF39B3D74DCE4CAF>]/Prev 4494028 >>^M
startxref^M
4663747^M
%%EOF^M
#!/bin/bash
echo "hello world" > ~/hello.txt
Would this work with a different file format? Does the embedded code need to be a binary executable?
As (fortunately), that's not part of the standard, you can't do that.
Unfortunately, the standard supports "launch actions", to execute arbitrary code with user confirmation. Those are now disabled by default and don't allow to execute embedded bulbs, but if enabled you could use that to execute arbitrary code that finds and executes the code embedded on the pdf.
The standard also supports javascript that excecutes sandboxed, but it a reader specific bug that allows may escaping the sandbox.

Getting the current working directory in Assembly

I'm working on an assembly code using Flat Assembler that would read a value from an .ini file, and, in order to do that, I'm trying to invoke the Kernel 32.dll GetPrivateProfileInt function.
There is only one problem with that: in order to properly read the file, I need to pass the full path of the .ini as a parameter to this function. I have tried to pass '.\config.ini' as a parameter and I have also tried to use MAX_PATH/rb MAX_PATH to get the full working directory (which is sometimes valid in FASM), but that didn't work either...
If anyone could help me, I would be grateful!
Here is my current code:
[...]
invoke GetPrivateProfileInt,.secname,.keyname,-1,.inifile
cmp eax,1
je .start
invoke MessageBoxA,0,.inifile,.secname,MB_ICONERROR
[...]
.inifile: db '.\config.ini',0
.secname: db 'config',0
.keyname: db 'advanced',0
(Note: this messagebox code is just something I included in order to know if that function was actually reading the value from the config.ini)
And the .ini file I'm trying to read:
[config]
advanced=1
Again, if anyone could help me, I would be grateful!
Actually, this behavior is described in MSDN.
lpFileName [in]
The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.
If you want to use exactly the current working directory (which is not always the one where the executable file resides), use GetCurrentDirectory API to get the current working directory and then append the configuration file after this string.
But usually you want to read the configuration file from the directory where the executable file is placed.
In these cases I use something like the following:
.aminitwindow:
; Create string with the filename of the INI file.
lea ebx, [.str]
invoke GetModuleFileNameA, NULL, ebx, 512
mov ecx, eax
.findloop:
dec eax
js .notfound
cmp byte [ebx+eax], '.'
je .found
jmp .findloop
.notfound:
mov eax, ecx
.found:
mov dword [ebx+eax], '.cfg'
mov byte [ebx+eax+4], 0
lea esi, [eax+16]
Here I construct the name of the configuration file, simply changing the extension of the executable file (from .exe to .cfg). If you want to use different name, simply scan back to the first "\" character and then add the whole filename of your config file.

Linux Scripting

Can you give me a sample on how to filter a certain keyword like for example "error" in the /var/log/messages and then send email if it finds real-time word for error.
I would just like to watch for error keyword in the /var/log/messages and then send it to my email address.
simply grepit.
tail -f log.log | grep error
This will list you all error you can then mail them
What you can do is this:
On a regular basis (which you decide), you:
copy the main file to another file
you DIFF on that file, only taking out the newly added parts (if the file is sequentially written, this will be a nice and clean block of lines, at the end of the file)
you copy the main file to the other file, again (this sets the new reference for the next check)
then you GREP on whatever you want, in the block of lines you've found 2 steps back
you report the found lines, using the wanted method (mail,..)

Bash script , error output redirection

I want to redirect the error
python: can't open file '/usr/bin/file': [Errno 2] No such file or directory
I used this command
python /usr/bin/file 2> /dev/zero
but this is hiding all the output in my file , so I want to redirect only the not found error and nothing else .
Binary file is scripted by me through python giving this
Enter your password:
Welcome User :)
Checking your Secure Code now ...
Secure Code OK , Enjoy !!
What is the folder path ? ### This is hidden when used the code ###
You want /dev/null, not /dev/zero, which is a generator for scripts (you can read it for an endless stream of zero bytes if you ever need one).
The syntax you show does in fact redirect only standard error; if standard output is lost, it's because of something else.

How to output latin characters in Windows Event Viewer

I have a service application that have to write information in the Windows Event Viewer. It happens that it have a version in Spanish and needs to have Latin characters in the text, so when the information is written to the Even Viewer it displays incorrectly. My .mc file is as follows:
; // ***** log_messages.mc *****
; // This is the header.
MessageIdTypedef=DWORD
SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
Warning=0x2:STATUS_SEVERITY_WARNING
Error=0x3:STATUS_SEVERITY_ERROR
)
FacilityNames=(System=0x0:FACILITY_SYSTEM
Runtime=0x2:FACILITY_RUNTIME
Stubs=0x3:FACILITY_STUBS
Io=0x4:FACILITY_IO_ERROR_CODE
)
LanguageNames=(Spanish=0x0c0a:MSG00c0a)
; // The following are message definitions.
MessageId=0x1
Severity=Informational
Facility=Runtime
SymbolicName=MSG_INFO
Language=Spanish
Información: %1
.
MessageId=0x2
Severity=Warning
Facility=Runtime
SymbolicName=MSG_WARNING
Language=Spanish
Precaución: %1
.
MessageId=0x3
Severity=Error
Facility=Runtime
SymbolicName=MSG_ERROR
Language=Spanish
Error: %1
.
When the information is displayed, for example an Information event the Latin characters are displayed incorrectly:
If someone have had this issue and could help me, thanks in regards.
So I solved it, the problem was when generating the .h and .rc files with mc.exe I used this parameters:
mc -U mymcfile.mc
Taking into account that the output should be in Windows in Unicode characters set, but the mc tool was taking the input as ANSI, so I add a parameter:
mc -u -U mymcfile.mc
At first it returned an error cuz the file was in ANSI, but I converted it to UNICODE and it worked fine after that. Hope this could help others...

Resources