แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - golfreeze

Pages: 1 ... 3 4 [5] 6 7 ... 73
61
=== freebsd 11.x 64bit compile directadmin and failed on snail

/usr/local/directadmin/custombuild/s-nail-14.9.19/src/mx/xtls.c:1937:20: warning: incompatible integer to pointer conversion assigning to 'const EVP_MD *'
      (aka 'const struct env_md_st *') from 'int' [-Wint-conversion]
         fprnt_mdp = a_XTLS_FINGERPRINT_DEFAULT_DIGEST();
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/directadmin/custombuild/s-nail-14.9.19/src/mx/xtls.c:1942:27: warning: implicit declaration of function 'TLS_client_method' is invalid in C99
      [-Wimplicit-function-declaration]
   if((ctxp = SSL_CTX_new(mx_XTLS_CLIENT_METHOD())) == NULL){
                          ^
/usr/local/directadmin/custombuild/s-nail-14.9.19/include/mx/gen-config.h:379:31: note: expanded from macro 'mx_XTLS_CLIENT_METHOD'
#define mx_XTLS_CLIENT_METHOD TLS_client_method
                              ^
/usr/local/directadmin/custombuild/s-nail-14.9.19/src/mx/xtls.c:1942:27: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const SSL_METHOD *'
      (aka 'const struct ssl_method_st *') [-Wint-conversion]
   if((ctxp = SSL_CTX_new(mx_XTLS_CLIENT_METHOD())) == NULL){
                          ^~~~~~~~~~~~~~~~~~~~~~~
/usr/local/directadmin/custombuild/s-nail-14.9.19/include/mx/gen-config.h:379:31: note: expanded from macro 'mx_XTLS_CLIENT_METHOD'
#define mx_XTLS_CLIENT_METHOD TLS_client_method
                              ^
/usr/include/openssl/ssl.h:2131:40: note: passing argument to parameter 'meth' here
SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);
                                       ^
4 warnings and 7 errors generated.
gmake[1]: *** [mk-config.mk:421: mx-072.o] Error 1
gmake[1]: Leaving directory '/usr/local/directadmin/custombuild/s-nail-14.9.19/.obj'
gmake: *** [makefile:25: build] Error 2
Could not find /usr/local/directadmin/scripts/directadmin_cron or it is empty

====> how to fixed
snail is use your old openssl and not openssl 1.1.1

and also my problem in the past.

You may set 0 as the version in custom_versions.txt for it.
cd /usr/local/directadmin/custombuild
vi custom_versions.txt
s-nail:0

=== manually install s-nail package in freebsd
pkg install s-nail

===then run setup again.
./setup auto

62
วันนี้มีเทส compile php5.6.x บน freebsd 12.x ดูครับแล้วพบว่ามี error เกี่ยวกับ onig_get_encoding
คือจริงๆ ใน directadmin ก็มีออก patch มาเพื่อแก้ไขตัว php_mb_regex_t

cd /usr/local/da/custombuild/php5.6/ext/mbstring

==== Start of Patch ====
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -454,7 +454,7 @@ static php_mb_regex_t *php_mbregex_compile_pattern(const char *pattern, int patlen, OnigOptionType options, OnigEncoding enc, OnigSyntaxType *syntax TSRMLS_DC)
   OnigUChar err_str[ONIG_MAX_ERROR_MESSAGE_LEN];

   found = zend_hash_find(&MBREX(ht_rc), (char *)pattern, patlen+1, (void **) &rc);
-   if (found == FAILURE || (*rc)->options != options || (*rc)->enc != enc || (*rc)->syntax != syntax) {
+   if (found == FAILURE || onig_get_options(*rc) != options || onig_get_encoding(*rc) != enc || onig_get_syntax(*rc) != syntax) {
      if ((err_code = onig_new(&retval, (OnigUChar *)pattern, (OnigUChar *)(pattern + patlen), options, enc, syntax, &err_info)) != ONIG_NORMAL) {
         onig_error_code_to_str(err_str, err_code, err_info);
         php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex compile err: %s", err_str);

==== End of Patch ====

OpenSSL version
It is known fact that PHP 5.x versions have issues to compile against OpenSSL 1.1.1. So first we need to install an alternative OpenSSL version. In FreeBSD ports we can find openssl-unsafe, which offers OpenSSL 1.0.2. So we install it

=== install portsnap on freebsd12.x
#portsnap fetch
#portsnap extract

cd /usr/ports/security/openssl-unsafe
make && make install

# /usr/local/openssl-unsafe/bin/openssl version
OpenSSL 1.0.2-chacha (1.0.2k-dev)

cd /usr/local/directadmin/custombuild
mkdir -p custom/php/
cp -p configure/php/configure.php5* custom/php/
mkdir -p custom/fpm/.custom_openssl
touch custom/fpm/.custom_openssl

perl -pi -e 's|with-openssl|with-openssl=/usr/local/openssl-unsafe|g' custom/php/configure.php5*

cd /usr/local/directadmin/custombuild
./build update
./build php

===> เปิดอีก session ทำการ copy patch ext/mbstring/php_mbregex.c เข้าไปทับตัวที่ download source php-5.6.40 ไปด้วยนะครับ =>
cd /usr/local/directadmin/custombuild
cp php_mbregex.c php-5.6.40/ext/mbstring/.

./build rewrite_confs

https://forum.directadmin.com/threads/migrating-from-openssl-to-openssl-unsafe.60104/


63
[Tue May 14 14:57:17.838720 2020] [proxy:error] [pid 20668:tid 140271263479552] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /usr/local/php72/sockets/web.sock (*) failed
[Tue May 14 14:57:17.838746 2020] [proxy_fcgi:error] [pid 20668:tid 140271263479552] [client 1.2.3.4:51451] AH01079: failed to make connection to backend: httpd-UDS

ทำการแก้ไขโดยทำการ restart php-fpm72 services 1 ครั้ง แล้วเข้าใช้งานอีกรอบก็จะทำให้ใช้งานได้ปกติครับ
สาเหตุน่าจะเกิดจากตอนทำการ compile php-fpm module แล้ว service ค้างค่า configure module เก่าไว้ครับ

==centos / ubuntu
systemctl restart php-fpm72

==freebsd
/usr/local/etc/rc.d/php-fpm72 restart

64
==exim 4.93.0.4 on directadmin could not send email , downgrade exim to 4.92.3
cd /usr/local/directadmin/custombuild
echo "exim:4.92.3:" > custom_versions.txt
./build exim


65
#pkg update and found error for wrong version and repo information
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2

=== fixed by
#pkg bootstrap -f
#pkg update -f
#pkg upgrade

or
#pkg install rsync

== then update path
/usr/libexec/locate.updatedb

==rsync installed done.
# rsync --version
rsync  version 3.1.3  protocol version 31
Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 32-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, no prealloc, file-flags

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

66
  +-------------------------------------+        +---------------------------------+
  |                 IPMI                |        |          GAMING CONSOLES        |
  |-------------------------------------|        |---------------------------------|
  | Sun SSP                 | $100,000+ |        | Xbox ONE X (RCE)     | $75,000+ |
  | Dell DRAC               | $100,000+ |        | Playstation 4 (RCE)  | $75,000+ |
  | HP iLO                  | $100,000+ |        | Nintendo (RCE)       | $50,000+ |
  | Supermicro IPMI         | $100,000+ |        +---------------------------------+
  | Cisco CIMC              | $50,000+  |
  | VNC, Teamviewer, Radmin | $50,000+  |
  | Other                   | $20,000+  |
  +-------------------------------------+

67
What is PGP (Pretty Good Privacy)?
Pretty Good Privacy (PGP) is a data encryption and decryption computer program that provides cryptographic privacy and authentication for data communication. PGP is often used for signing, encrypting, and decrypting texts, emails, files, directories, and whole disk partitions and to increase the security of email communications.
For more information:  http://en.wikipedia.org/wiki/Pretty_Good_Privacy

What is GPG (GNU Privacy Guard)?
GNU Privacy Guard is a free alternative to the PGP suite (owned by Symantec).  It is interoperable with PGP and operates similarly.
For more information:  http://en.wikipedia.org/wiki/GNU_Privacy_Guard

Start Using PGP
Gnupg.org has many resources to help get you started.  The site provides a nice GUI (graphical user interface) for Windows and Mac users.  Windows users can download GPG4Win from http://www.gpg4win.org/.  Mac users can download GPG Tools Suite from https://gpgtools.org/

Public and Private Keys
Understanding public and private keys is the key to using PGP encryption.  The user on each end of the communication must have a PGP key. Each public key is bound to an email address.  The sender will encrypt the message with the recipient’s public PGP key and the sender’s signature. When the recipient receives the message, they must use their passphrase (private key) in order to decrypt the message. 

Obtaining Keys
The following will show how to obtain your private and public key with GNU Privacy Assistant (GPG4Win).  The process is essentially the same on Apple machines.  However, you are able to search public keys by email address on Apple machines (on Windows you have to have the Key ID or the public key text/file).​

68
command , shell script ,tool , crontab / cp and history command
« on: เมษายน 19, 2020, 08:52:54 PM »
===copy command with same name and added _bck end of file name
cp events.py{,_bck}
ls
events.py
events.py_bck

history
!789
Run command on line 789 again

69
ในการ transfer file ระหว่าง os window -> os linux หรือ unix
บางทีจะมีพวก อักขระพิเศษต่างๆที่เพิ่มไประหว่างทาง ช่วงที่มีการ scp , wget ก็เกิดขึ้นได้
หลังจากที่ไฟล์ ที่เราต้องการ download วิ่งมาถึง linux , unix แล้ว

ต้องทำการรัน command dos2unix เพื่อลบอักขระพิเศษเหล่านั้นออก เพื่อให้สามารถ execute ได้
ถ้าไม่ทำอาจจะขึ้น ": no file or directory found" or error on line อะไรประมาณนี้ครับ

วิธีการรันก็คือ ถ้าชื่อไฟล์ที่มีการ transfer มาเป็น file.sh
#dos2unix file.sh

เท่านี้เราก็จะสามารถ รัน shell script ได้อย่างไม่มี error เรื่องอักขระพิเศษแล้วครับ

 ;)

70
ในกรณีที่สงสัยว่าเครื่อง window os. โดนของ เราสามารถติดตั้ง tool process-explorer ช่วยในการค้นหา หรือ ช่วยในการ tracking process หาต้นตอปัญหา cpu,ram peak ได้ครับ

https://docs.microsoft.com/th-th/sysinternals/downloads/process-explorer

หรือจะใช้อีกตัวที่เป็น process hacker tool
https://processhacker.sourceforge.io/downloads.php

ลองดูนะครับ

71
วันนี้เจอโจทย์ว่า directadmin ทำการ block port หลังจาก client authentication เสร็จแล้ว  ทำให้ไม่สามารถ list file และ folder ขึ้นมาแสดงได้
จะเป็น port range Passive mode : 35000-35999
ซึ่งระบุใน pure-ftpd.conf
configure file

เราสามารถ ระบุ port range ลงใน csf firewall ได้ดังนี้
#vi /etc/csf/csf.conf

TCP_IN="35000:35999"

systemctl restart pure-ftpd
systemctl restart csf

เท่านี้ user ก็จะสามารถ list file & folder ได้ละครับผม
: )  ;)

72
command , shell script ,tool , crontab / basic command for xargs by golfreeze
« on: เมษายน 05, 2020, 04:15:41 PM »
=== Basic command xargs เป็นการส่งผ่าน command echo เพื่อนำค่านั้นไปรันงานต่อ

=== -t = verbose
echo  "file1 file2 file3" | xargs -t touch
=result
touch file1 file2 file3

=== -p = prompt interactive
echo  "file1 file2 file3" | xargs -p touch
=result
touch file1 file2 file3 ?...y

=== -n show 1 column with touch
echo  "file1 file2 file3" |  xargs -n 1 -t touch
As you can see from the verbose output below, the touch command is executed separately for each argument:
=result
touch file1
touch file2
touch file3

=== -n show number string
echo a b c d e f | xargs -n 3
a b c
d e f

=== read value from file ips.txt
== ips.txt
8.8.8.8
1.1.1.1
xargs -t -L 1 -a ips.txt ping -c 1
=result
ping -c 1 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=68.1 ms

...
ping -c 1 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=59 time=21.4 ms

===Combine find command and Xargs with Grep command
find . -name '*.c' | xargs grep ‘stdlib.h’

==== Combind find command with rm file with space file name
find . -name "*.c" -print0 | xargs -0 rm -rf


73
วิธีการเพิ่ม policy ingress และลบ policy in security group aws-cli
ก่อนอื่นต้องทำการติดตั้ง awscli version 2 ก่อนนะครับ

====CentOS/Redhat8 install awscli2
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip”
unzip awscliv2.zip
sudo ./aws/install

#export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
#aws --version

== ทำการ export AWS_PROFILE ก่อนเพื่อให้เรียกใช้งาน aws-cli
== และมีสิทธิ์ในการเข้าถึง ec2 ได้ แต่ต้องผูก role EC2FullAccess เพื่อให้เข้าถึง ec2 security group ได้ด้วยนะครับ
export AWS_PROFILE=default
aws configure list

###check descibe-instances
#aws ec2 describe-instances --output table --region ap-southeast-1

###check instance-attribute and
#aws ec2 describe-instance-attribute --instance-id i-01ec81abpacketlove2 --attribute groupSet

###check authorize-security-group-ingress
#aws ec2 authorize-security-group-ingress help
#aws ec2 authorize-security-group-ingress --group-id sg-0b4d3fpacketlove2 --protocol tcp --port 8000 --cidr $ip/32
aws ec2 authorize-security-group-ingress --group-id sg-0b4d3fpacketlove2 --ip-permissions IpProtocol=tcp,FromPort=8000,ToPort=8000,IpRanges='[{CidrIp=103.246.17.148/32,Description="Allow-from-pkl-nw"}]'

## check command to revoke-security-group-ingress
#aws ec2 revoke-security-group-ingress --group-name MySecurityGroup --protocol tcp --port 22 --cidr 203.0.113.0/24
aws ec2 revoke-security-group-ingress --group-id sg-0b4d3fpacketlove2 --ip-permissions '[{"IpProtocol": "icmp", "FromPort": 3, "ToPort": 4, "IpRanges": [{"CidrIp": "0.0.0.0/0"}]}]'
aws ec2 revoke-security-group-ingress --group-id sg-0b4d3fpacketlove2 --ip-permissions IpProtocol=tcp,FromPort=8000,ToPort=8000,IpRanges='[{CidrIp=103.246.17.148/32,Description="Allow-from-pkl-nw"}]'

## check policy security-group for ingress(inbound)+egress(outbound) rule
aws ec2 describe-security-groups --group-id sg-0b4d3fpacketlove2

74
เช่นถ้ามีโจทย์ว่าต้องการให้สร้าง list domain : *.hosting.pkl.com
ต้องทำการเพิ่ม โดเมนนี้ใน allowed_sub_domains.list ก่อน
/usr/local/directadmin/data/admin/allowed_sub_domains.list

vi allowed_sub_domains.list
ทำการเพิ่ม hosting.pkl.com ลงในไฟล์

chown diradmin:diradmin /usr/local/directadmin/data/admin/allowed_sub_domains.list

แล้วทำการเพิ่ม ลงไปใน directadmin.conf
check_subdomain_owner=1

for this domain, in case you want to use this domain for subdomain hosting (as full domains)

Ensure you chown the file to diradmin:diradmin.


If there is a match (starting from the top domain.com down, to sub.domain.com), then DA will check the subdomain.list file for domain.com (under the true owner, if that's on the box) and if a subdomain already  matches that name, the creation will abort.
The true domain's subdomains have priority if they already exists.

75
=> เจอ error "directadmin private_html Symbolic link not allowed or link target not accessible" ตอนที่เปิดใช้งาน ssl แล้วให้ symlink วิ่งไปจาก private_html -> public_html

ลองสังเกตดูที่ไฟล์ options.conf จะมีตัว
vi /usr/local/directadmin/custombuild/options.conf

harden_symlinks_patch=yes

ให้ทำการแก้ไขเป็น
harden_symlinks_patch=no

แล้วทำการ build apache ใหม่ครับ
cd /usr/local/directadmin/custombuild/
./build apache

ทำการเข้าเทส url https อีกรอบก็จะใช้งานได้ลนะครับผม

Pages: 1 ... 3 4 [5] 6 7 ... 73