├── Dockerfile
├── base-image
└── Dockerfile
├── README.md
├── startup.sh
├── scripts
├── supermicro
│ └── startup.sh
├── inspur
│ └── startup.sh
├── sugo
│ ├── startup.sh
│ └── encrypt.js
├── h3c
│ ├── startup.sh
│ └── jviewer-template.jnlp
├── dell
│ └── startup.sh
└── lenovo
│ └── startup.sh
└── LICENSE
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM registry.cn-qingdao.aliyuncs.com/x-lab/kvm-base:v1.0.0
2 |
3 | COPY ./scripts /
4 |
5 | COPY startup.sh /startapp.sh
6 |
--------------------------------------------------------------------------------
/base-image/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM domistyle/idrac6
2 |
3 | MAINTAINER zhangdahai
4 |
5 | RUN apt-get update && \
6 | apt-get install -y vim net-tools && \
7 | apt-get install -y icedtea-netx && \
8 | apt-get install -y ipmitool && \
9 | apt-get install -y curl nodejs
10 |
11 | RUN sed -i '701,705d' /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security ; \
12 | sed -i 's|jdk.tls.disabledAlgorithms|# jdk.tls.disabledAlgorithms|g' /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/java.security
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RackShift 远程 WEBKVM
2 | ## 使用方法(IDRAC8)
3 | ```
4 | docker run -d -p 5800:5800 -e VENDOR=DELL -e HOST=xxx -e USER=xxx -e PASSWD=xxx -e APP_NAME=IDRAC8 registry.cn-qingdao.aliyuncs.com/x-lab/kvm:v1.0.0
5 | ```
6 | 直接打开 http://ip:5800
7 | 其中 VENDOR 支持的参数为:Inspur,DELL,H3C,Supermicro,Suma
8 |
9 | # 已支持的机型
10 | | 品牌 | BMC 版本 |
11 | | :-----| :----- |
12 | | 浪潮 | 4.40 |
13 | | 曙光 | 1.80 |
14 | | 华3 | 1.30 |
15 | | 超微 | 1.71 |
16 | | DELL | 2.50 IDRAC8 等同 |
17 | | 联想 | 7.2 |
18 | 其他不支持的版本欢迎提交 ISSUE
19 |
20 | # 效果图
21 | 
22 |
--------------------------------------------------------------------------------
/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | VENDOR=${VENDOR}
4 |
5 | if [ -z $VENDOR ];then
6 | # shellcheck disable=SC1073
7 | echo "NO VENDOR Provided"
8 | echo "possible Vendor is :"
9 | echo "Inspur,DELL,H3C,Supermicro,Suma"
10 | exit 1
11 | fi
12 |
13 | if [[ $VENDOR == DEL* ]];then
14 | dir=/dell
15 | elif [[ $VENDOR == Inspur* ]];then
16 | dir=/inspur
17 | elif [[ $VENDOR == *H3C* ]];then
18 | dir=/h3c
19 | elif [[ $VENDOR == Supermicro* ]];then
20 | dir=/supermicro
21 | elif [[ $VENDOR == Suma* ]];then
22 | dir=/sugo
23 | elif [[ $VENDOR == Lenovo* ]];then
24 | dir=/lenovo
25 | else
26 | echo "Not supported Vendor: $VENDOR"
27 | exit 1
28 | fi
29 |
30 | /bin/bash $dir/startup.sh
31 |
--------------------------------------------------------------------------------
/scripts/supermicro/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Set BMC info
4 |
5 | HOST=${HOST}
6 | USER=${USER}
7 | PASSWD=${PASSWD}
8 | export DISPLAY_WIDTH=1024
9 | export DISPLAY_HEIGHT=800
10 |
11 | if [ -z "$HOST" ];then
12 | echo please set "HOST" environment !
13 | exit 1
14 | fi
15 |
16 | if [ -z "$USER" ];then
17 | echo please set "USER" environment !
18 | exit 1
19 | fi
20 |
21 | if [ -z "$PASSWD" ];then
22 | echo please set "PASSWD" enviroment !
23 | exit 1
24 | fi
25 |
26 |
27 | # Login to BMC WEB Server to Get JNLP
28 |
29 | GET_COOKIEURL="https://${HOST}/cgi/login.cgi"
30 | PAYLOAD="name=${USER}&pwd=${PASSWD}"
31 |
32 | GET_COOKIE=`curl -i -k -X POST -d "${PAYLOAD}" "${GET_COOKIEURL}"`
33 |
34 | if [ -z "$GET_COOKIE" ];then
35 | echo "failed to login to BMC: https://${HOST}"
36 | exit 1
37 | fi
38 |
39 | SESSION=`echo "$GET_COOKIE" | grep -e "SID=[^;]\+" | awk -F ' ' '{print $2}'`
40 |
41 | if [ -z $SESSION ];then
42 | echo "cannot get sesion_cookie from response : $SESSION"
43 | exit 1
44 | fi
45 |
46 | wget -O /app/jviewer.jnlp --tries=2 --no-check-certificate --header "Cookie:${SESSION};" "https://${HOST}/cgi/url_redirect.cgi?url_name=ikvm&url_type=jwsk"
47 |
48 | if [ -f /app/jviewer.jnlp ];then
49 | chmod +x /app/jviewer.jnlp
50 | fi
51 | javaws /app/jviewer.jnlp
52 |
--------------------------------------------------------------------------------
/scripts/inspur/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Set BMC info
4 |
5 | HOST=${HOST}
6 | USER=${USER}
7 | PASSWD=${PASSWD}
8 |
9 | if [ -z "$HOST" ];then
10 | echo please set "HOST" environment !
11 | exit 1
12 | fi
13 |
14 | if [ -z "$USER" ];then
15 | echo please set "USER" environment !
16 | exit 1
17 | fi
18 |
19 | if [ -z "$PASSWD" ];then
20 | echo please set "PASSWD" enviroment !
21 | exit 1
22 | fi
23 |
24 |
25 | # Login to BMC WEB Server to Get JNLP
26 |
27 | GET_COOKIEURL="https://${HOST}/rpc/WEBSES/create.asp"
28 | PAYLOAD="WEBVAR_USERNAME=${USER}&WEBVAR_PASSWORD=${PASSWD}"
29 |
30 | GET_COOKIE=`curl -i -k -X POST -H \'Content-type\':\'application/json\' -d "${PAYLOAD}" "${GET_COOKIEURL}"`
31 |
32 | if [ -z "$GET_COOKIE" ];then
33 | echo "failed to login to BMC: https://${HOST}"
34 | exit 1
35 | fi
36 |
37 | SESSION=`echo "$GET_COOKIE" | grep SESSION_COOKIE | awk -F "'" '{print $4}'`
38 |
39 | if [ -z $SESSION ];then
40 | echo "cannot get sesion_cookie from response : $SESSION"
41 | exit 1
42 | fi
43 |
44 | wget -O /app/jviewer.jnlp --tries=2 --no-check-certificate --header "Cookie:SessionCookie=${SESSION};" "https://${HOST}/Java/jviewer.jnlp?EXTRNIP=${HOST}&JNLPSTR=JViewer"
45 |
46 | if [ -f /app/jviewer.jnlp ];then
47 | chmod +x /app/jviewer.jnlp
48 | fi
49 | javaws /app/jviewer.jnlp
50 |
--------------------------------------------------------------------------------
/scripts/sugo/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Set BMC info
4 |
5 | HOST=${HOST}
6 | USER=`node /sugo/encrypt.js ${USER} 16| xargs`
7 | PASSWD=`node /sugo/encrypt.js ${PASSWD} | xargs`
8 | export DISPLAY_WIDTH=1024
9 | export DISPLAY_HEIGHT=768
10 |
11 | if [ -z "$HOST" ];then
12 | echo please set "HOST" environment !
13 | exit 1
14 | fi
15 |
16 | if [ -z "$USER" ];then
17 | echo please set "USER" environment !
18 | exit 1
19 | fi
20 |
21 | if [ -z "$PASSWD" ];then
22 | echo please set "PASSWD" enviroment !
23 | exit 1
24 | fi
25 |
26 | # Login to BMC WEB Server to Get JNLP
27 |
28 | GET_COOKIEURL="https://${HOST}/api/secure_session"
29 | PAYLOAD="username=${USER}&password=${PASSWD}"
30 |
31 | GET_COOKIE=`curl -i -k -X POST -d "${PAYLOAD}" "${GET_COOKIEURL}"`
32 |
33 | if [ -z "$GET_COOKIE" ];then
34 | echo "failed to login to BMC: https://${HOST}"
35 | exit 1
36 | fi
37 |
38 | SESSION=`echo "$GET_COOKIE" | grep -e "QSESSIONID=[^;]\+" | awk -F ' ' '{print $2}'`
39 | CSRF=`echo "$GET_COOKIE" | awk -F 'CSRFToken' '{print $2}' | awk -F ' ' '{print $2}' | awk -F '"' '{printf $2}'`
40 |
41 | if [ -z $SESSION ];then
42 | echo "cannot get sesion_cookie from response : $SESSION"
43 | exit 1
44 | fi
45 |
46 | wget -O /app/jviewer.jnlp --no-check-certificate --header="Cookie:$SESSION" --header="X-CSRFTOKEN:$CSRF" "https://${HOST}/api/kvmjnlp?&JNLPSTR=JViewer&locale=root"
47 |
48 | if [ -f /app/jviewer.jnlp ];then
49 | chmod +x /app/jviewer.jnlp
50 | fi
51 | javaws /app/jviewer.jnlp
52 |
--------------------------------------------------------------------------------
/scripts/h3c/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Set BMC info
4 |
5 | HOST=${HOST}
6 | USER=${USER}
7 | PASSWD=${PASSWD}
8 | export DISPLAY_WIDTH=1024
9 | export DISPLAY_HEIGHT=800
10 |
11 | if [ -z "$HOST" ];then
12 | echo please set "HOST" environment !
13 | exit 1
14 | fi
15 |
16 | if [ -z "$USER" ];then
17 | echo please set "USER" environment !
18 | exit 1
19 | fi
20 |
21 | if [ -z "$PASSWD" ];then
22 | echo please set "PASSWD" enviroment !
23 | exit 1
24 | fi
25 |
26 |
27 | #Base64 encode
28 |
29 | USER=`echo -n $USER | base64 | base64`
30 | PASSWD=`echo -n $PASSWD | base64 | base64`
31 |
32 | # Login to BMC WEB Server to Get JNLP
33 |
34 | GET_COOKIEURL="https://${HOST}/api/session"
35 | PAYLOAD="username=${USER}&password=${PASSWD}&log_type=1"
36 |
37 | GET_COOKIE=`curl -i -k -X POST -d "${PAYLOAD}" "${GET_COOKIEURL}"`
38 |
39 | if [ -z "$GET_COOKIE" ];then
40 | echo "failed to login to BMC: https://${HOST}"
41 | exit 1
42 | fi
43 |
44 | SESSION=`echo "$GET_COOKIE" | grep -e "QSESSIONID=[^;]\+" | awk -F ' ' '{print $2}'`
45 | CSRF=`echo "$GET_COOKIE" | awk -F 'CSRFToken' '{print $2}' | awk -F ' ' '{print $2}' | awk -F '"' '{printf $2}'`
46 |
47 | if [ -z $SESSION ];then
48 | echo "cannot get sesion_cookie from response : $SESSION"
49 | exit 1
50 | fi
51 |
52 | #GET jnlp token
53 | TOKEN_RES=`curl -i -k -X GET -H "Cookie:$SESSION;" -H "X-CSRFTOKEN:$CSRF" "https://${HOST}/api/kvm/token"`
54 | TOKEN=`echo $TOKEN_RES | awk -F 'token' '{print $2}' | awk -F '"' '{printf $3}'`
55 | SESSION=`echo "$SESSION" | awk -F ';' '{printf $1}' | awk -F 'QSESSIONID=' '{print $2}'`
56 |
57 | cp /h3c/jviewer-template.jnlp /app/jviewer.jnlp
58 |
59 | sed -i "s/\${HOST}/${HOST}/g" /app/jviewer.jnlp
60 | sed -i "s/\${TOKEN}/${TOKEN}/g" /app/jviewer.jnlp
61 | sed -i "s/\${SESSION}/${SESSION}/g" /app/jviewer.jnlp
62 |
63 | if [ -f /app/jviewer.jnlp ];then
64 | chmod +x /app/jviewer.jnlp
65 | fi
66 | javaws /app/jviewer.jnlp
67 |
--------------------------------------------------------------------------------
/scripts/dell/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Set BMC info
4 |
5 | HOST=${HOST}
6 | USER=${USER}
7 | PASSWD=${PASSWD}
8 | export DISPLAY_WIDTH=1280
9 | export DISPLAY_HEIGHT=768
10 |
11 | if [ -z "$HOST" ];then
12 | echo please set "HOST" environment !
13 | exit 1
14 | fi
15 |
16 | if [ -z "$USER" ];then
17 | echo please set "USER" environment !
18 | exit 1
19 | fi
20 |
21 | if [ -z "$PASSWD" ];then
22 | echo please set "PASSWD" enviroment !
23 | exit 1
24 | fi
25 |
26 | getIdracVersion(){
27 | firm_version=`ipmitool -I lanplus -H ${HOST} -U ${USER} -P ${PASSWD} mc info | grep "Firmware Revision" | awk -F ':' '{printf $NF}' | xargs`
28 | if [ -z "$firm_version" ];then
29 | echo "get idrac version faild , no ipmi response [mc info]"
30 | exit 1
31 | fi
32 |
33 | if [[ $firm_version == 1* ]];then
34 | version="idrac7"
35 | elif [[ $firm_version == 2* ]];then
36 | version="idrac8"
37 | else
38 | version="idrac9"
39 | fi
40 | echo $version
41 | }
42 |
43 | getIdracVersion
44 |
45 |
46 | # Login to BMC WEB Server to Get JNLP
47 |
48 | GET_COOKIEURL="https://${HOST}/data/login"
49 | PAYLOAD="user=${USER}&password=${PASSWD}"
50 |
51 | GET_COOKIE=`curl -i -k -X POST -d "${PAYLOAD}" "${GET_COOKIEURL}"`
52 |
53 | if [ -z "$GET_COOKIE" ];then
54 | echo "failed to login to BMC: https://${HOST}"
55 | exit 1
56 | fi
57 |
58 | SESSION=`echo "$GET_COOKIE" | grep -e "Cookie:[^;]\+" | awk -F ' ' '{print $2}'`
59 | ST1=`echo "$GET_COOKIE" | grep ST1 | awk -F 'ST1=' '{print $2}' | awk -F ',ST2' '{print $1}'| xargs`
60 | ST2=`echo "$GET_COOKIE" | grep ST2 | awk -F 'ST2=' '{print $2}' | awk -F '' '{printf $1}' | xargs`
61 |
62 | if [ -z $SESSION ];then
63 | echo "cannot get sesion_cookie from response : $SESSION"
64 | exit 1
65 | fi
66 |
67 | MIS=`date +%s`
68 | wget -O /app/jviewer.jnlp --no-check-certificate --header="Cookie:$SESSION" --header="ST2:$ST2" "https://${HOST}/viewer.jnlp(${HOST}@0@ssasa@${MIS}@ST1=$ST1)"
69 |
70 | if [ -f /app/jviewer.jnlp ];then
71 | chmod +x /app/jviewer.jnlp
72 | fi
73 | javaws /app/jviewer.jnlp
74 |
--------------------------------------------------------------------------------
/scripts/lenovo/startup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Set BMC info
4 |
5 | HOST=${HOST}
6 | USER=${USER}
7 | PASSWD=${PASSWD}
8 | export DISPLAY_WIDTH=1280
9 | export DISPLAY_HEIGHT=768
10 |
11 | if [ -z "$HOST" ];then
12 | echo please set "HOST" environment !
13 | exit 1
14 | fi
15 |
16 | if [ -z "$USER" ];then
17 | echo please set "USER" environment !
18 | exit 1
19 | fi
20 |
21 | if [ -z "$PASSWD" ];then
22 | echo please set "PASSWD" enviroment !
23 | exit 1
24 | fi
25 |
26 | getIdracVersion(){
27 | firm_version=`ipmitool -I lanplus -H ${HOST} -U ${USER} -P ${PASSWD} mc info | grep "Firmware Revision" | awk -F ':' '{printf $NF}' | xargs`
28 | if [ -z "$firm_version" ];then
29 | echo "get idrac version faild , no ipmi response [mc info]"
30 | exit 1
31 | fi
32 |
33 | if [ "$firm_version" = "7.20" ];then
34 | version="sr650"
35 | fi
36 | echo $version
37 | }
38 |
39 | getIdracVersion
40 |
41 |
42 | # Login to BMC WEB Server to Get JNLP
43 |
44 | GET_TOKENURL="https://${HOST}/api/login"
45 | JSON='{
46 | "username": "'${USER}'",
47 | "password": "'${PASSWD}'"
48 | }'
49 |
50 | GET_TOKEN=`curl -k -X POST -d "${JSON}" ${GET_TOKENURL} --header "Content-Type: application/json"`
51 |
52 | if [ -z "$GET_TOKEN" ];then
53 | echo "failed to login to BMC: https://${HOST}"
54 | exit 1
55 | fi
56 |
57 | TOKEN_SESSION=`echo ${GET_TOKEN}|sed 's/\"//g'|awk -F':' '{print $2}'|sed 's/}//g'`
58 |
59 | if [ -z $TOKEN_SESSION ];then
60 | echo "cannot get sesion_cookie from response : $TOKEN_SESSION"
61 | exit 1
62 | fi
63 | verty_url="https://${HOST}/api/providers/rp_jnlp"
64 | DOWN_JAVA_CLIENT="https://${HOST}/download/rp.jnlp"
65 | verty_result=`curl -s -k -H "Authorization: Bearer ${TOKEN_SESSION}" ${verty_url}`
66 | result=`echo ${verty_result}|awk -F',' '{print $1}'|awk -F':' '{print $2}'|sed 's/ //g'`
67 |
68 | if [ "$result" = "0" ];then
69 | curl -s -k -H "Authorization: Bearer ${TOKEN_SESSION}" ${DOWN_JAVA_CLIENT} > /app/jviewer.jnlp
70 | fi
71 | if [ -f /app/jviewer.jnlp ];then
72 | chmod +x /app/jviewer.jnlp
73 | fi
74 | javaws /app/jviewer.jnlp
75 |
--------------------------------------------------------------------------------
/scripts/h3c/jviewer-template.jnlp:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JViewer
5 | American Megatrends, Inc.
6 | JViewer Console Redirection Application
7 | JViewer Console Redirection Application
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | -apptype
53 | JViewer
54 | -hostname
55 | ${HOST}
56 | -kvmmode
57 | 2
58 | -kvmtoken
59 | ${TOKEN}
60 | -kvmsecure
61 | 0
62 | -kvmport
63 | 7578
64 | -vmsecure
65 | 0
66 | -cdstate
67 | 1
68 | -fdstate
69 | 1
70 | -hdstate
71 | 1
72 | -cdport
73 | 5120
74 | -fdport
75 | 5122
76 | -hdport
77 | 5123
78 | -cdnum
79 | 2
80 | -fdnum
81 | 1
82 | -hdnum
83 | 2
84 | -singleportenabled
85 | 0
86 | -ldapuser
87 | 0
88 | -extendedpriv
89 | 259
90 | -keyboardlayout
91 | AD
92 | -lang
93 | EN
94 | -retrycount
95 | 4
96 | -retryinterval
97 | 5
98 | -kvmstatus
99 | 1
100 | -kvmcdnum
101 | 2
102 | -kvmfdnum
103 | 1
104 | -kvmhdnum
105 | 2
106 | -webcookie
107 | ${SESSION}
108 | -isUIS
109 | 0
110 | -isSpe
111 | 16978692
112 | -oemfeatures
113 | 170
114 |
115 |
116 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/scripts/sugo/encrypt.js:
--------------------------------------------------------------------------------
1 | let process = require('process')
2 |
3 | function blowfish() {
4 |
5 | function blowfish(e) {
6 | for (var t = e.length, n = 0; t > n; n++)
7 | e[n] = String.fromCharCode(255 & e[n], e[n] >>> 8 & 255, e[n] >>> 16 & 255, e[n] >>> 24 & 255);
8 | return e.join("")
9 | }
10 |
11 | this.key = "megarac",
12 | this._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
13 | this.length = 24,
14 | this.n = 16,
15 | this.p_box = new Array(18),
16 | this.b_box = new Array(18),
17 | this.s_box = new Array(4),
18 | this.resetKey = function () {
19 | this.p_box = Array(608135816, 2242054355, 320440878, 57701188, 2752067618, 698298832, 137296536, 3964562569, 1160258022, 953160567, 3193202383, 887688300, 3232508343, 3380367581, 1065670069, 3041331479, 2450970073, 2306472731),
20 | this.b_box = this.p_box,
21 | this.s_box = Array(Array(3509652390, 2564797868, 805139163, 3491422135, 3101798381, 1780907670, 3128725573, 4046225305, 614570311, 3012652279, 134345442, 2240740374, 1667834072, 1901547113, 2757295779, 4103290238, 227898511, 1921955416, 1904987480, 2182433518, 2069144605, 3260701109, 2620446009, 720527379, 3318853667, 677414384, 3393288472, 3101374703, 2390351024, 1614419982, 1822297739, 2954791486, 3608508353, 3174124327, 2024746970, 1432378464, 3864339955, 2857741204, 1464375394, 1676153920, 1439316330, 715854006, 3033291828, 289532110, 2706671279, 2087905683, 3018724369, 1668267050, 732546397, 1947742710, 3462151702, 2609353502, 2950085171, 1814351708, 2050118529, 680887927, 999245976, 1800124847, 3300911131, 1713906067, 1641548236, 4213287313, 1216130144, 1575780402, 4018429277, 3917837745, 3693486850, 3949271944, 596196993, 3549867205, 258830323, 2213823033, 772490370, 2760122372, 1774776394, 2652871518, 566650946, 4142492826, 1728879713, 2882767088, 1783734482, 3629395816, 2517608232, 2874225571, 1861159788, 326777828, 3124490320, 2130389656, 2716951837, 967770486, 1724537150, 2185432712, 2364442137, 1164943284, 2105845187, 998989502, 3765401048, 2244026483, 1075463327, 1455516326, 1322494562, 910128902, 469688178, 1117454909, 936433444, 3490320968, 3675253459, 1240580251, 122909385, 2157517691, 634681816, 4142456567, 3825094682, 3061402683, 2540495037, 79693498, 3249098678, 1084186820, 1583128258, 426386531, 1761308591, 1047286709, 322548459, 995290223, 1845252383, 2603652396, 3431023940, 2942221577, 3202600964, 3727903485, 1712269319, 422464435, 3234572375, 1170764815, 3523960633, 3117677531, 1434042557, 442511882, 3600875718, 1076654713, 1738483198, 4213154764, 2393238008, 3677496056, 1014306527, 4251020053, 793779912, 2902807211, 842905082, 4246964064, 1395751752, 1040244610, 2656851899, 3396308128, 445077038, 3742853595, 3577915638, 679411651, 2892444358, 2354009459, 1767581616, 3150600392, 3791627101, 3102740896, 284835224, 4246832056, 1258075500, 768725851, 2589189241, 3069724005, 3532540348, 1274779536, 3789419226, 2764799539, 1660621633, 3471099624, 4011903706, 913787905, 3497959166, 737222580, 2514213453, 2928710040, 3937242737, 1804850592, 3499020752, 2949064160, 2386320175, 2390070455, 2415321851, 4061277028, 2290661394, 2416832540, 1336762016, 1754252060, 3520065937, 3014181293, 791618072, 3188594551, 3933548030, 2332172193, 3852520463, 3043980520, 413987798, 3465142937, 3030929376, 4245938359, 2093235073, 3534596313, 375366246, 2157278981, 2479649556, 555357303, 3870105701, 2008414854, 3344188149, 4221384143, 3956125452, 2067696032, 3594591187, 2921233993, 2428461, 544322398, 577241275, 1471733935, 610547355, 4027169054, 1432588573, 1507829418, 2025931657, 3646575487, 545086370, 48609733, 2200306550, 1653985193, 298326376, 1316178497, 3007786442, 2064951626, 458293330, 2589141269, 3591329599, 3164325604, 727753846, 2179363840, 146436021, 1461446943, 4069977195, 705550613, 3059967265, 3887724982, 4281599278, 3313849956, 1404054877, 2845806497, 146425753, 1854211946), Array(1266315497, 3048417604, 3681880366, 3289982499, 290971e4, 1235738493, 2632868024, 2414719590, 3970600049, 1771706367, 1449415276, 3266420449, 422970021, 1963543593, 2690192192, 3826793022, 1062508698, 1531092325, 1804592342, 2583117782, 2714934279, 4024971509, 1294809318, 4028980673, 1289560198, 2221992742, 1669523910, 35572830, 157838143, 1052438473, 1016535060, 1802137761, 1753167236, 1386275462, 3080475397, 2857371447, 1040679964, 2145300060, 2390574316, 1461121720, 2956646967, 4031777805, 4028374788, 33600511, 2920084762, 1018524850, 629373528, 3691585981, 3515945977, 2091462646, 2486323059, 586499841, 988145025, 935516892, 3367335476, 2599673255, 2839830854, 265290510, 3972581182, 2759138881, 3795373465, 1005194799, 847297441, 406762289, 1314163512, 1332590856, 1866599683, 4127851711, 750260880, 613907577, 1450815602, 3165620655, 3734664991, 3650291728, 3012275730, 3704569646, 1427272223, 778793252, 1343938022, 2676280711, 2052605720, 1946737175, 3164576444, 3914038668, 3967478842, 3682934266, 1661551462, 3294938066, 4011595847, 840292616, 3712170807, 616741398, 312560963, 711312465, 1351876610, 322626781, 1910503582, 271666773, 2175563734, 1594956187, 70604529, 3617834859, 1007753275, 1495573769, 4069517037, 2549218298, 2663038764, 504708206, 2263041392, 3941167025, 2249088522, 1514023603, 1998579484, 1312622330, 694541497, 2582060303, 2151582166, 1382467621, 776784248, 2618340202, 3323268794, 2497899128, 2784771155, 503983604, 4076293799, 907881277, 423175695, 432175456, 1378068232, 4145222326, 3954048622, 3938656102, 3820766613, 2793130115, 2977904593, 26017576, 3274890735, 3194772133, 1700274565, 1756076034, 4006520079, 3677328699, 720338349, 1533947780, 354530856, 688349552, 3973924725, 1637815568, 332179504, 3949051286, 53804574, 2852348879, 3044236432, 1282449977, 3583942155, 3416972820, 4006381244, 1617046695, 2628476075, 3002303598, 1686838959, 431878346, 2686675385, 1700445008, 1080580658, 1009431731, 832498133, 3223435511, 2605976345, 2271191193, 2516031870, 1648197032, 4164389018, 2548247927, 300782431, 375919233, 238389289, 3353747414, 2531188641, 2019080857, 1475708069, 455242339, 2609103871, 448939670, 3451063019, 1395535956, 2413381860, 1841049896, 1491858159, 885456874, 4264095073, 4001119347, 1565136089, 3898914787, 1108368660, 540939232, 1173283510, 2745871338, 3681308437, 4207628240, 3343053890, 4016749493, 1699691293, 1103962373, 3625875870, 2256883143, 3830138730, 1031889488, 3479347698, 1535977030, 4236805024, 3251091107, 2132092099, 1774941330, 1199868427, 1452454533, 157007616, 2904115357, 342012276, 595725824, 1480756522, 206960106, 497939518, 591360097, 863170706, 2375253569, 3596610801, 1814182875, 2094937945, 3421402208, 1082520231, 3463918190, 2785509508, 435703966, 3908032597, 1641649973, 2842273706, 3305899714, 1510255612, 2148256476, 2655287854, 3276092548, 4258621189, 236887753, 3681803219, 274041037, 1734335097, 3815195456, 3317970021, 1899903192, 1026095262, 4050517792, 356393447, 2410691914, 3873677099, 3682840055), Array(3913112168, 2491498743, 4132185628, 2489919796, 1091903735, 1979897079, 3170134830, 3567386728, 3557303409, 857797738, 1136121015, 1342202287, 507115054, 2535736646, 337727348, 3213592640, 1301675037, 2528481711, 1895095763, 1721773893, 3216771564, 62756741, 2142006736, 835421444, 2531993523, 1442658625, 3659876326, 2882144922, 676362277, 1392781812, 170690266, 3921047035, 1759253602, 3611846912, 1745797284, 664899054, 1329594018, 3901205900, 3045908486, 2062866102, 2865634940, 3543621612, 3464012697, 1080764994, 553557557, 3656615353, 3996768171, 991055499, 499776247, 1265440854, 648242737, 3940784050, 980351604, 3713745714, 1749149687, 3396870395, 4211799374, 3640570775, 1161844396, 3125318951, 1431517754, 545492359, 4268468663, 3499529547, 1437099964, 2702547544, 3433638243, 2581715763, 2787789398, 1060185593, 1593081372, 2418618748, 4260947970, 69676912, 2159744348, 86519011, 2512459080, 3838209314, 1220612927, 3339683548, 133810670, 1090789135, 1078426020, 1569222167, 845107691, 3583754449, 4072456591, 1091646820, 628848692, 1613405280, 3757631651, 526609435, 236106946, 48312990, 2942717905, 3402727701, 1797494240, 859738849, 992217954, 4005476642, 2243076622, 3870952857, 3732016268, 765654824, 3490871365, 2511836413, 1685915746, 3888969200, 1414112111, 2273134842, 3281911079, 4080962846, 172450625, 2569994100, 980381355, 4109958455, 2819808352, 2716589560, 2568741196, 3681446669, 3329971472, 1835478071, 660984891, 3704678404, 4045999559, 3422617507, 3040415634, 1762651403, 1719377915, 3470491036, 2693910283, 3642056355, 3138596744, 1364962596, 2073328063, 1983633131, 926494387, 3423689081, 2150032023, 4096667949, 1749200295, 3328846651, 309677260, 2016342300, 1779581495, 3079819751, 111262694, 1274766160, 443224088, 298511866, 1025883608, 3806446537, 1145181785, 168956806, 3641502830, 3584813610, 1689216846, 3666258015, 3200248200, 1692713982, 2646376535, 4042768518, 1618508792, 1610833997, 3523052358, 4130873264, 2001055236, 3610705100, 2202168115, 4028541809, 2961195399, 1006657119, 2006996926, 3186142756, 1430667929, 3210227297, 1314452623, 4074634658, 4101304120, 2273951170, 1399257539, 3367210612, 3027628629, 1190975929, 2062231137, 2333990788, 2221543033, 2438960610, 1181637006, 548689776, 2362791313, 3372408396, 3104550113, 3145860560, 296247880, 1970579870, 3078560182, 3769228297, 1714227617, 3291629107, 3898220290, 166772364, 1251581989, 493813264, 448347421, 195405023, 2709975567, 677966185, 3703036547, 1463355134, 2715995803, 1338867538, 1343315457, 2802222074, 2684532164, 233230375, 2599980071, 2000651841, 3277868038, 1638401717, 4028070440, 3237316320, 6314154, 819756386, 300326615, 590932579, 1405279636, 3267499572, 3150704214, 2428286686, 3959192993, 3461946742, 1862657033, 1266418056, 963775037, 2089974820, 2263052895, 1917689273, 448879540, 3550394620, 3981727096, 150775221, 3627908307, 1303187396, 508620638, 2975983352, 2726630617, 1817252668, 1876281319, 1457606340, 908771278, 3720792119, 3617206836, 2455994898, 1729034894, 1080033504), Array(976866871, 3556439503, 2881648439, 1522871579, 1555064734, 1336096578, 3548522304, 2579274686, 3574697629, 3205460757, 3593280638, 3338716283, 3079412587, 564236357, 2993598910, 1781952180, 1464380207, 3163844217, 3332601554, 1699332808, 1393555694, 1183702653, 3581086237, 1288719814, 691649499, 2847557200, 2895455976, 3193889540, 2717570544, 1781354906, 1676643554, 2592534050, 3230253752, 1126444790, 2770207658, 2633158820, 2210423226, 2615765581, 2414155088, 3127139286, 673620729, 2805611233, 1269405062, 4015350505, 3341807571, 4149409754, 1057255273, 2012875353, 2162469141, 2276492801, 2601117357, 993977747, 3918593370, 2654263191, 753973209, 36408145, 2530585658, 25011837, 3520020182, 2088578344, 530523599, 2918365339, 1524020338, 1518925132, 3760827505, 3759777254, 1202760957, 3985898139, 3906192525, 674977740, 4174734889, 2031300136, 2019492241, 3983892565, 4153806404, 3822280332, 352677332, 2297720250, 60907813, 90501309, 3286998549, 1016092578, 2535922412, 2839152426, 457141659, 509813237, 4120667899, 652014361, 1966332200, 2975202805, 55981186, 2327461051, 676427537, 3255491064, 2882294119, 3433927263, 1307055953, 942726286, 933058658, 2468411793, 3933900994, 4215176142, 1361170020, 2001714738, 2830558078, 3274259782, 1222529897, 1679025792, 2729314320, 3714953764, 1770335741, 151462246, 3013232138, 1682292957, 1483529935, 471910574, 1539241949, 458788160, 3436315007, 1807016891, 3718408830, 978976581, 1043663428, 3165965781, 1927990952, 4200891579, 2372276910, 3208408903, 3533431907, 1412390302, 2931980059, 4132332400, 1947078029, 3881505623, 4168226417, 2941484381, 1077988104, 1320477388, 886195818, 18198404, 3786409e3, 2509781533, 112762804, 3463356488, 1866414978, 891333506, 18488651, 661792760, 1628790961, 3885187036, 3141171499, 876946877, 2693282273, 1372485963, 791857591, 2686433993, 3759982718, 3167212022, 3472953795, 2716379847, 445679433, 3561995674, 3504004811, 3574258232, 54117162, 3331405415, 2381918588, 3769707343, 4154350007, 1140177722, 4074052095, 668550556, 3214352940, 367459370, 261225585, 2610173221, 4209349473, 3468074219, 3265815641, 314222801, 3066103646, 3808782860, 282218597, 3406013506, 3773591054, 379116347, 1285071038, 846784868, 2669647154, 3771962079, 3550491691, 2305946142, 453669953, 1268987020, 3317592352, 3279303384, 3744833421, 2610507566, 3859509063, 266596637, 3847019092, 517658769, 3462560207, 3443424879, 370717030, 4247526661, 2224018117, 4143653529, 4112773975, 2788324899, 2477274417, 1456262402, 2901442914, 1517677493, 1846949527, 2295493580, 3734397586, 2176403920, 1280348187, 1908823572, 3871786941, 846861322, 1172426758, 3287448474, 3383383037, 1655181056, 3139813346, 901632758, 1897031941, 2986607138, 3066810236, 3447102507, 1393639104, 373351379, 950779232, 625454576, 3124240540, 4148612726, 2007998917, 544563296, 2244738638, 2330496472, 2058025392, 1291430526, 424198748, 50039436, 29584100, 3605783033, 2429876329, 2791104160, 1057563949, 3255363231, 3075367218, 3463963227, 1469046755, 985887462))
22 | }
23 | ,
24 | this.setKey = function () {
25 | this.resetKey();
26 | for (var e, t = this.key, n = t.length, i = 0, l = 0; l < this.n + 2; l++) {
27 | e = 0;
28 | for (var a = 0; 4 > a; a++)
29 | e = e << 8 | t.charCodeAt(i).toString(10),
30 | i += 1,
31 | i >= n && (i = 0);
32 | this.p_box[l] = this.p_box[l] ^ e
33 | }
34 | for (var r = 0, s = 0, l = 0; l < this.n + 2; l += 2) {
35 | var o = this.encipher(r, s);
36 | r = o[0],
37 | s = o[1],
38 | this.p_box[l] = r,
39 | this.p_box[l + 1] = s
40 | }
41 | for (var l = 0; 4 > l; l++)
42 | for (var i = 0; 256 > i; i += 2) {
43 | var o = this.encipher(r, s);
44 | r = o[0],
45 | s = o[1],
46 | this.s_box[l][i] = r,
47 | this.s_box[l][i + 1] = s
48 | }
49 | }
50 | ,
51 | this.rotatedWord = function (e) {
52 | var t;
53 | return t = (255 & e) << 24 | (e >>> 8 & 255) << 16 | (e >>> 16 & 255) << 8 | e >>> 24 & 255
54 | }
55 | ,
56 | this.encrypt = function (e, t) {
57 | this.setKey(),
58 | t = null == t ? this.length : t;
59 | for (var n = t - e.length, i = 0; n > i; i++)
60 | e += String.fromCharCode(0);
61 | for (var l = 0, a = 0, r = 0, s = [], o = "", c = 0; t > c;)
62 | a = this.strToInt(e.substring(4 * l, 4 * l + 4)),
63 | r = this.strToInt(e.substring(4 * (l + 1), 4 * (l + 1) + 4)),
64 | a = this.rotatedWord(a),
65 | r = this.rotatedWord(r),
66 | s = this.encipher(a, r),
67 | a = this.rotatedWord(s[0]),
68 | r = this.rotatedWord(s[1]),
69 | o += a + ",",
70 | o += r + ",",
71 | c += 8,
72 | l += 2;
73 | return this.encode(o)
74 | }
75 | ,
76 | this.decrypt = function (t) {
77 | for (var n = [], i = strToInt(t), l = 0; l < i.length; l += 2) {
78 | var a = this.decipher(i[l], i[l + 1]);
79 | n.push(a[0], a[1])
80 | }
81 | return e(n)
82 | }
83 | ,
84 | this.encipher = function (e, t) {
85 | for (var n, i = 0; i < this.n; i++)
86 | e ^= this.p_box[i],
87 | t = this.f(e) ^ t,
88 | n = e,
89 | e = t,
90 | t = n;
91 | return n = e,
92 | e = t,
93 | t = n,
94 | t ^= this.p_box[this.n],
95 | e ^= this.p_box[this.n + 1],
96 | Array(e, t)
97 | }
98 | ,
99 | this.decipher = function (e, t) {
100 | return e ^= this.p_box[17],
101 | t ^= this.f(e) ^ this.p_box[16],
102 | e ^= this.f(t) ^ this.p_box[15],
103 | t ^= this.f(e) ^ this.p_box[14],
104 | e ^= this.f(t) ^ this.p_box[13],
105 | t ^= this.f(e) ^ this.p_box[12],
106 | e ^= this.f(t) ^ this.p_box[11],
107 | t ^= this.f(e) ^ this.p_box[10],
108 | e ^= this.f(t) ^ this.p_box[9],
109 | t ^= this.f(e) ^ this.p_box[8],
110 | e ^= this.f(t) ^ this.p_box[7],
111 | t ^= this.f(e) ^ this.p_box[6],
112 | e ^= this.f(t) ^ this.p_box[5],
113 | t ^= this.f(e) ^ this.p_box[4],
114 | e ^= this.f(t) ^ this.p_box[3],
115 | t ^= this.f(e) ^ this.p_box[2],
116 | e ^= this.f(t),
117 | Array(binxor(t, this.p_box[0]), binxor(e, this.p_box[1]))
118 | }
119 | ,
120 | this.f = function (e) {
121 | return this.modularAdd(this.modularAdd(this.s_box[0][e >>> 24 & 255], this.s_box[1][e >>> 16 & 255]) ^ this.s_box[2][e >>> 8 & 255], this.s_box[3][255 & e])
122 | }
123 | ,
124 | this.encode = function (e) {
125 | var t, n, i, l, a, r, s, o, c, d = "", u = 0;
126 | e = this._utf8_encode(e),
127 | e = e.substring(0, e.length - 1),
128 | newArr = e.split(",");
129 | for (var _ = [], h = 0, p = 0; p < newArr.length; p++)
130 | for (var f = 0; 4 > f; f++)
131 | _[h] = newArr[p] % 256,
132 | h++,
133 | newArr[p] = newArr[p] >>> 8;
134 | for (o = _.length; o >= 1;) {
135 | switch (c = 3 > o ? o : 3,
136 | t = 0,
137 | n = 0,
138 | i = 0,
139 | l = 0,
140 | a = _[u],
141 | r = _[u + 1],
142 | s = _[u + 2],
143 | u += 3,
144 | c) {
145 | case 3:
146 | l = 63 & s,
147 | i = (192 & s) >>> 6;
148 | case 2:
149 | i |= (15 & r) << 2,
150 | n = (240 & r) >>> 4;
151 | case 1:
152 | n |= (3 & a) << 4,
153 | t = (252 & a) >>> 2;
154 | break;
155 | default:
156 | console("error")
157 | }
158 | switch (o -= c,
159 | c) {
160 | case 1:
161 | i = 64;
162 | case 2:
163 | l = 64;
164 | case 3:
165 | break;
166 | default:
167 | console("error")
168 | }
169 | d = d + this._keyStr.charAt(t) + this._keyStr.charAt(n) + this._keyStr.charAt(i) + this._keyStr.charAt(l)
170 | }
171 | return d
172 | }
173 | ,
174 | this._utf8_encode = function (e) {
175 | e = e.replace(/\r\n/g, "\n");
176 | for (var t = "", n = 0; n < e.length; n++) {
177 | var i = e.charCodeAt(n);
178 | 128 > i ? t += String.fromCharCode(i) : i > 127 && 2048 > i ? (t += String.fromCharCode(i >> 6 | 192),
179 | t += String.fromCharCode(63 & i | 128)) : (t += String.fromCharCode(i >> 12 | 224),
180 | t += String.fromCharCode(i >> 6 & 63 | 128),
181 | t += String.fromCharCode(63 & i | 128))
182 | }
183 | return t
184 | }
185 | ,
186 | this.strToInt = function (e) {
187 | var t = new Array
188 | , n = e.length
189 | , i = 0
190 | , l = 0;
191 | do
192 | t[l++] = e.charCodeAt(i++) + (e.charCodeAt(i++) << 8) + (e.charCodeAt(i++) << 16) + (e.charCodeAt(i++) << 24);
193 | while (n > i);
194 | return t
195 | }
196 | ,
197 | this.modularAdd = function (e, t) {
198 | var n = (65535 & e) + (65535 & t)
199 | , i = (e >> 16) + (t >> 16) + (n >> 16);
200 | return (i << 16) + (65535 & n)
201 | }
202 | }
203 | let e = new blowfish();
204 | console.log(encodeURIComponent(e.encrypt(process.argv[2], process.argv[3])));
--------------------------------------------------------------------------------