47 skills found · Page 1 of 2
rakitzis / Rcrc shell -- independent re-implementation for Unix of the Plan 9 shell (from circa 1992)
SaumyajeetDas / CVE 2023 46604 RCE Reverse Shell Apache ActiveMQAchieving a Reverse Shell Exploit for Apache ActiveMQ (CVE_2023-46604)
benavento / RcRc — The Plan 9 Shell (Standalone Unix port)
TieDyedDevil / XS[ABANDONED] An extensible shell (descended from es and rc) having functional semantics and a conventional syntax.
germanztz / Gnome Shell Extension Rclone ManagerIs like Dropbox sync client but for more than 30 services, adds an indicator to the top panel so you can manage the rclone profiles configured in your system, perform operations such as mount as remote, watch for file modifications, sync with remote storage, navigate it's main folder. Also, it shows the status of each profile so you can supervise the operations, and provides an easy access log of events. Backup and restore the rclone configuration file, so you won't have to configure all your devices one by one
z1un / NC BeanShell RCECNVD-2021-30167 用友NC BeanShell远程代码执行
gh0x0st / RCE Web Shell PythonA python approach to interacting with web shells.
RuoJi6 / CVE 2025 55182 RCE ShellBurp Suite/antsword - Interactive shell (HTTP hijack + POST + AES-256-CBC/BASE64)
indradhanush / Rc ShellA UNIX shell
craigemery / DotFilesThe .rc files I use in my day-to-day shell work (mostly bash)
tangcr / Redis Redis是什么 Redis是一个NOSQL,NOSQL有许多种,它们分为: 列存储,如:Hbase、Cassandra这种 文档存储,如:MongoDB(首推) key-value存储,如:Berkeley DB、MemcacheDB、Redis,其中Redis最强 图存储,这块基本不用,有:Neo4j、Versant XML存储,如:Berkeley DB Xml还有XBASE,ORACLE很早已经支持这种存储方式了 光知道这些NOSQL的名词是没有用的,关键在于要知道在哪种场景下选用哪种NOSQL才是我们真正要去掌握的。 我们这边说Redis就拿Redis说事吧,它能干什么呢? Redis基础应用场景 web间session共享,即多个war工程共享一个session 分布式缓存,因为redis为键值对,而且它提供了丰富的adapter可以支持到C、.net、java客户端,因此对于异质平台间进行数据交换起到了作用,因此它可以用作大型系统的分布式缓存,并且其setnx的锁常被用于”秒杀“,”抢红包“这种电商活动场景中。 安装Redis 我本来想在这儿写”Redis上的‘坑‘“,最后我还是觉得把它放到后面章节中去写吧,因为中国人的思维是先有感性再有理性的一种逆向思维,其实这点很像美国人,因此中国人在世界上是最聪明的民族之一,所以我们还是先从动手搭一个Redis的环境来说起吧,老规矩,红色加粗很重要。 一定要使用Linux来布署Redis,请不要偷懒使用Redis 2.8.1 for windows那个版本,如果你使用了这个版本你将无法跟上这一系列教程的步伐。因为Redis为GCC+这样的东西开发出来的,它天生就是运行在LINUX/Unix环境下的,而那个windows版的Redis是一个”烟“割版,而且是一个unofficial的版本,非官方授权的哈。 先从Docker开始 如果已经有Linux/Unix环境的同协们可以直接跳过这一章。 我们这边要开始变态了,因为我们要真正开始踏上SOA、PAAS、互联网的脚步了。 如果对于没有Linux/Unix环境的用户来说,我在这边推荐使用docker,即boot2docker windows版来安装,它下载后是一个这样的文件 安装前把你的网络连接中的IPV6协议前的勾去掉 双击它,在安装时记得选择Virtual-Box选项,因为docker本为linux/unix下之物,因此为了在windows下使用docker,boot2docker内嵌了一个virtualbox来虚拟docker的环境。 装完后它会在你的桌面上生成一个蓝色的图标,双击它,它会打开一个绿色的字,黑色的背景像matrix电影里的那种命令行窗口,这就是Docker。 装完后运行: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker@boot2docker:~$ docker run hello-world 看到下面这些提示 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 Hello from Docker. This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the “hello-world” image from the Docker Hub. (Assuming it was not already locally available.) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash For more examples and ideas, visit: http://docs.docker.com/userguide/ 说明你的Docker安装成功了。 在Docker中安装unix环境 有了Docker我们就用Docker虚拟一个Ubuntu(UNIX)环境吧,在这边我们使用的是Ubuntu14。 ubuntu14请下载这个包:戳: 下载Ubuntu14包 下载后直接在docker下运行下面这条命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 cat ubuntu-14.04-x86_64.tar.gz |docker import - ubuntu:ubuntu14 这个过程会很快,完成后查看自己的image: 成功导入了ubuntu,这样我们就可以在Docker中运行出一个自己的ubuntu了。 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker run -i -t ubuntu:ubuntu14 /bin/bash 以上运行后,进入了该ubuntu的bash环境。 注:如果上述命令出错,可以使用下面这条命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker run -i -t ubuntu:ubuntu14 //bin/bash 两个 “/” 哈 如果你能看到类似于root@ubuntu14_这样的命令行界面说明你的ubuntu14也已经安装成功了,下面我们就要在这个docker->ubuntu14中安装和布署我们的Redis了,这个过程和在Linux下一样。 在ubuntu14下先安装SSHD,以便于我们使用WINSCP这样的SFTP工具来管理我们的ubuntu14中的文件系统 在ubuntu14中安装SSHD 第一步: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker run -t -i ubuntu/mk:v1 /bin/bash 进入我们的ubuntu环境,这边的ubuntu/mk就是我本机的docker中ubuntu14 container(容器)的名字,如果按照上面的延续此处可以替换成ubuntu:ubuntu14这个名字吧。 第二步: 升级一下你的apt-get,它就是一个命令行IE下载工具,如果你不update,那么你apt-get的源、内核都为旧的,因此为了升级apt-get请键入下面的命令 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 apt-get update 这个过程很快(依赖于你的网络环境) 第三步: 下载和安装openssh组件 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 apt-get install openssh-server openssh-client 第四步: 修改你的root密码 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 passwd 键入两次你的root密码,我这边都为6个小写的a 第五步: 退出容器,并保存以上修改,如果docker在退出后你接着退出docker环境或者是关机那么刚才的4步全部不生效,你一定要commit它才能生效,为此: 你先要知道你刚才用docker run命令运行的ubuntu14的容器的ID,你可以使用 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker ps -a 来查到你latest的一次容器的ID,它是一组16进制一样的编码如:1edfb9aabde8890,有了这个container id我们就可以commit我们刚才装的openssh的环境了 commit刚才在容器中所做的修改 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker commit 1edfb9aabde8890 ubuntu:ssh 第六步: 运行带有openssh的ubuntu14以便于我们使用winscp这样的SFTP工具连入我们的ubuntu14中去,依次输入下面的命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker kill $(docker ps -q) 杀掉正在运行的所有的container的进程 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker rm $(docker ps -a -q) 删除所有在进程中的容器,以上2步又被称为docker大扫除 Docker是这样的机制的,它可以开启多个容器,每个容器带着一堆的image(镜像),要删一个镜像必须先停止这个镜像所在的容器,再把这个镜像删除,因此我们使用上面这两条命令对于Docker来一个大扫除。 接着我们先查一下我们目前手头有的镜像 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker images 你会看到一个images列表,里面有我们的ubuntu:14,有我们的ubuntu:ssh也有一个hello-world,我们把ubuntu:14这个镜像删了吧(为了保持干净哈) 每个image也它自己的id,即image id,因此你用docker images命令查到该镜像的id后可以使用: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker rmi imageid 这条命令把一个不用的镜像给删了。 接下去我们要启动我们的ubuntu14:ssh了,可以使用下面这条命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker -d -p 122:22 ubuntu:ssh //usr/sbin/sshd -D 这条命令的意思为: -d即把我们的image启动在后台进程,它将会是一个daemon进程,而不会像刚才我们使用-t一样,一旦exit后该image进程也自动退出了 -p为端口映射,什么意思呢,这边要说一下docker的端口映射问题。我们知道docker安装后它会利用virtualbox中的vhost only的nat机制来建立一个虚拟的IP 可以打开我们的virtualbox中在菜单”全局->设定->网络”中进行查找 所以我们可以知道一旦boot2docker环境运行后它的地址为192.168.56.*这个段,一般为192.168.56.101这个地址,你可以在boot2docker启动后直接使用winscp边入这个docker环境。 地址:192.168.56.101 端口:22 用户名:docker 密码:tcuser 以上为默认值,具体地址按照你的virtualbox中在boot2docker安装时自动给出的设置来做参考。 而, 我们在这个docker中安装了一个ubuntu14:ssh的image,然后用后台进程的方式打开了这个ubuntu14:ssh,因此它自己也有一个IP(可能是172也可能是169段),具体不得而知,一般来说它是每次启动镜像后自己变换的(可以使用动态网络域名绑定docker中镜像的ip来达到域名不变的目的-集群环境下有用)。 我们都知道ssh是以端口22来进行TCP连接的,因此我们把ubuntu14的IP上的22端口映射到了我们的docker主机192.168.56.101上的122端口。 参数//usr/sbin/sshd -D代表该镜像启动会的entrypoint即启动后再启动一个什么命令,在最后的-D(大写的D)告诉docker这是一个启动文件 于是,一旦该命令发出后,显示image启动的提示后(启动后你会得到一个image id)你就可以直接打开你的winscp使用: 地址:192.168.56.101 端口:122 (此处是122,不是22,因为我们把image的22端口映射到了192.168.56.101-docker主机上的122端口了) 用户名:root 密码:aaaaaa 即可以连入我们的ubuntu14环境了,如果此时你安装了putty还可以使用putty+winscp直接进入ubuntu14的命令行环境中去,于是你就有ubuntu14的试验环境了。 在ubuntu14下安装redis 网上很多在ubuntu14下安装redis的教程都不对的,大家看了要上当的,原因在于如下,请各位看完: 网上的redis环境搭建直接使用的是apt-get update完后用wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server 这样的方式来安装的,这样装固然方便,可是也因为方便所以取到的redis不是最新的redis版本,一般为2.8.x版或者是redis3.0.rc,这依赖于你的unit/linux所连接的wget库 redis为c写成,它的2.4-2.8版都为不稳定版或者是缺少功能或者是有bug,而这些bug在你如果真正使用redis作为网站生产环境时将会因为这些bug而无法面对峰涌而来的巨大并发,因此当有这样的redis运行了一段时间后你的生产环境会面临着巨大的压力 还是redis不够新不够稳定的原因,由于在redis3前redis还不支持集群、主备高可用方案的功能,因此不得不依靠于繁杂的打补丁式的如:linux/unix-keepalive或者是haproxy这种系统级层面然后写一堆的复杂脚本去维护你的redis集群,还要用外部手段(Linux/Unix Shell脚本)去维护多个redis节点间的缓存数据同步。。。这这这。。。不复合我们的网站扩容、增量、运维和面对巨大用户(万级并发-最高支持百万用户如:新浪微博、微信)的场景 因此,我在这边推荐大家使用下面我将要使用的“下载源码包结合你本机的Linux/Unix内核进行实时编译”的安装过程。 第一步:下载redis目前最稳定版本也是功能最完善,集群支持最好并加入了sentinel(哨兵-高可用)功能的redis3.0.7版即redis-stable版,为此我们需要获取redis-stable版 redis官方下载连接 就是用的这个redis-stable.tar.gz包,这是我在写博客时目前最新最稳定版本,修复了大量的BUG和完善了功能。 第二步: 下载后我们把该包上传到我们的docker中的ubuntu14中,我们把它放在/opt目录下 然后我们使用tar -zxvf redis-stable.tar.gz对它进行解压 解压后它就会生成一个redis-stable目录,进入该目录 cd redis-stable 别急,我们先一会编译和安装它 第三步:编译安装redis 我们先输入gcc -v 这个命令来查看我们的gcc版本,如果它低于4.2以下那么你在编译redis3.0.7时一定会碰到大量的出错信息,如前面所述,redis为gcc写成,最新的redis需要gcc4.2-5这个版本才能进行编译,而一般去年或者之前装的linux/unix 的 gcc都为4.0以下或者甚至是3.x版。 升级GCC先 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 apt-get install build-essential 因此apt-get update显得很重要,要不然你获取的gcc也将不是最新的版本,目前我的gcc为5.3.1为这周刚做的升级。 升级后我们开始编译redis3.0.7了,为此我们需要在redis-stable目录下 键入如下命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 make PREFIX=/usr/local/redis1 install 我们告知我们的GCC把redis-stable编译并同时安装在/usr/local/redis1目录下 这个过程很快,可能只有10秒钟时间(依据你的机器来说,建议使用>=8gb, 4核CPU的PC机),然后我们就可以看到everything ok了。我们进入/usr/local/redis1就可以看到我们刚才安装的redis3.0.7稳定版了。 我们进入我们的redis目录 cd /usr/local/redis1/bin 在此目录下我们即可以运行我们的redis server了,不过请别急,在启动前我们需要对redis进行一些配置。 我的博客面对的是“全栈式”工程师的,架构师只是成为全栈式工程师中的一个起点,如果你不会搭环境那么你就不能接触到最新的技术,因此这就是许多程序员工作了近5年,7年结果发觉也只会一个SSH的主要原因。 Redis3配置要领 使用winscp通过122连入docker下的ubuntu14,进行redis的配置。 我们需要编辑的文件为/usr/local/redis1/bin/redis.conf这个文件 [plain] view plain copy 在CODE上查看代码片派生到我的代码片 daemonize yes # When running daemonized, Redis writes a pid file in /var/run/redis.pid by # default. You can specify a custom pid file location here. pidfile "/var/run/redis/redis1.pid" # Accept connections on the specified port, default is 6379. # If port 0 is specified Redis will not listen on a TCP socket. port 7001 我们把: daemonize设为yes,使得redis以后台进程的方式来运行,你可以认为为“server”模式,如果redis以server模式运行的话它会生成一个pid文件 ,因此我们把它的路径放在/var/run/redis目录中,并命名它为redis1.pid文件 ,为此你需要在/var/run目录下建立redis这个目录 端口号我们把它设为7001,这样好辩识,因为将来我们会进一步做redis集群,所以我们的redis都为redis1, redis2, redis3那么我们的端口号也为7001, 7002, 7003。。。这样来延续。那么很多同协这时要问了,“为什么我们不把它命名成master, slave1, slave2这样的名字呢?”,理由很简单,无论是现在的hadoop还是zookeeper它们的集群是跨机房的,多个master间也有MASTER-SLAVE模式互为备份,因为一些大型网站不仅仅只有一个IDC机房,它们一般都会有2个,3个IDC机房,或者是在同一个IDC机房中有“跨机柜”的布署来形成超大规模集群,就和ALI的TAOBAO网一样,它在北美都有机房,因此当你需要在LOCAL NATIVE建一个IDC机房,在北美再做一个机房,你不要想把一个MASTER设在中国,SLAVE设到美国去,而是多地甚至是多机柜都有MASTER,一旦一个MASTER宕机了,这种集群会通过一个叫“选举策略”选出一个节点把这个节点作为当前“群”的MASTER,因此我们的命名才会是redis1, redis2, redis3...这样来命名的。 此处把原来的: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 save 900 1 save 300 10 save 60 10000 中的300 10 和60 10000注释掉。这边代表的是: redis以每900秒写一次、300秒写10次,60秒内写1万次这样的策略把缓存放入一个叫.rdb的磁盘文件中,这点和ehcache或者是memcache很像,以便于redis在重启时可以从本地持久化文件中找出关机前的数据记录。 如果按照默认的话,此三个策略会轮流起效,在大并发环境中,这样的写策略将会对我们的性能造成巨大的影响,因此我们这边只保留900秒写1次这条策略,这边有人会问,如果你这样会有数据丢失怎么办。。。别急,这个问题我们后面会解答,这涉及到redis的“正确”使用,如果它只是一个缓存,我相信5分钟内缓存的丢失此时程序直接访问数据库也不会有太大问题,又要保证数据完整性又要保证性能这本身是一个矛与盾的问题,除非你钱多了烧那我会给出你一个烧钱的配置策略,连新浪都不会这么烧钱,呵呵。 dbfilename,此处我们维持redis原有的缓存磁盘文件的原名 dir "/usr/local/redis1/data"为rdb文件所在的目录 这边大家要注意的是一个是只能写文件名,另一个地方只能写目录名。 为此我们需要在/usr/local/redis1下建立 data目录。 把此处的appendonly设为no,这样我们就关闭了Redis的AOF功能。 AOF 持久化记录服务器执行的所有写操作命令,并在服务器启动时,通过重新执行这些命令来还原数据集。AOF是redis在集群或者是高可用环境下的一个同步策略,它会不断的以APPEND的模式把redis的缓存中的数据从一个节点写给另一个节点,它对于数据的完整性保证是要高于rdb模式的。 RDB 是一个非常紧凑(compact)的文件,它保存了 Redis 在某个时间点上的数据集。 这种文件非常适合用于进行备份: 比如说,你可以在最近的 24 小时内,每小时备份一次 RDB 文件,并且在每个月的每一天,也备份一个 RDB 文件。 这样的话,即使遇上问题,也可以随时将数据集还原到不同的版本。RDB 非常适用于灾难恢复(disaster recovery):它只有一个文件,并且内容都非常紧凑,可以(在加密后)将它传送到别的数据中心如阿里的mysql异地机房间使用FTP传binlog的做法。 按照官方的说法,启用AOF功能,可以在redis高可用环境中如果发生了故障客户的数据不会有高于2秒内的历史数据丢失,它换来的代价为高昂的I/O开销,有些开发者为了追求缓存中的数据100%的正确有时会碰到因为redis在AOF频繁刷新时整个环境如死机一的情况,并且你会看到恶梦一般的”Asynchronous AOF fsync is taking too long “警告信息,这是因为redis它是单线程的,它在进行I/O操作时会阻塞住所有的操作,包括登录。。。这个很可怕,不过这个BUG/ISSUE已经在最新redis中进行了优化,它启用了另一根进程来进行AOF刷新,包括优化了RDB持久化功能,这也是为什么我让大家一定一定要用最新最稳定版的redis的原因。 一般默认情况下redis内的rdb和AOF功能同为开启, 如果RDB的数据不实时,同时使用两者时服务器重启也只会找AOF文件。 因为RDB文件只用作后备用途,建议只在Slave上持久化RDB文件,而且只要15分钟备份一次就够了,所以我只保留save 900 1这条规则。 如果Enalbe AOF: 好处是在最恶劣情况下也只会丢失不超过两秒数据,启动脚本较简单只load自己的AOF文件就可以了。 代价一是带来了持续的IO,二是AOF rewrite的最后将rewrite过程中产生的新数据写到新文件造成的阻塞几乎是不可避免的。只要硬盘许可,应该尽量减少AOF rewrite的频率,AOF重写的基础大小默认值64M太小了,可以设到5G以上。默认超过原大小100%大小时重写,这边可以设定一个适当的数值。 如果不Enable AOF ,仅靠Master-Slave Replication 实现高可用性也可以。能省掉极大的IO也减少了rewrite时带来的系统波动。代价是如果Master/Slave同时倒掉(那你的网站基本也就歇了),会丢失十几分钟的数据,启动脚本也要比较两个Master/Slave中的RDB文件,载入较新的那个。新浪微博就选用了这种架构。 最后我们不要忘了设一个redis的log文件,在此我们把它设到了/var/log/redis目录,为此我们需要在/var/log目录下建立一个redis目录。 好了,保存后我们来启动我们的redis吧。 我们使用以下这条命令来启动我们的redis server。 然后我们在我们的windows机上装一个windows版的redis 2.8.1 for windows(只用它来作为redis的client端) 然后我们在windows环境下使用: redis-cli -p 7001 -h 192.168.56.101 咦,没反映,连不上,哈哈。。。。。。 那是肯定连不上的,因为: 我们刚才在用docker启动ubuntu14时使用docker -d -p 122:22 ubuntu:ssh //usr/sbin/sshd -D来启动的,这边我们并未把redis服务的7001端口映射到192.168.56.101这台docker主机上,怎么可以通过windows主机(可能windows的ip为169.188.xx.xx)来访问docker内的进程服务呢?对吧,为此我们:先把刚才做了这么多的更改docker commit成一个新的image如:redis:basic吧。 然后我们对docker进行一次大扫除,然后我们启动redis:basic这个image并使用以下命令: [plain] view plain copy 在CODE上查看代码片派生到我的代码片 docker -d -p 122:22 -p 7001:7001 redis:basic //usr/sbin/sshd -D 看,此处我们可以使用多个-p来作docker内容器的多端口映射策略(它其实使用的就是iptables命令)。 好了,用putty连入这个image的进程并启动redis服务,然后我们拿windows中的redis-cli命令来连。 如果在linux环境下还是没有连通(可能的哦),那是因为你没有禁用linux下的防火墙,我们可以使用iptables -F来禁用linux的防火墙或者使用: vi /etc/selinux/config 然后把 SELINUX=enforcing 这句用”#“注释掉 增加一句: SELINUX=disabled #增加 这样每次启动后linux都不会有iptables的困扰了(这是在本机环境下这么干哦,如果你是生产环境请自行加iptables策略以允许redis服务端口可以被访问)。 看到下面这个PONG即代表你的redis服务已经在网络环境中起效了。 下面我们要开始使用Java客户端来连我们的Redis Service了。 使用Spring Data + JEDIS来连接Redis Service Spring+Session+Redis pom.xml 在此我们需要使用spring data和jedis,下面给出相关的maven配置 [html] view plain copy 在CODE上查看代码片派生到我的代码片 <dependencies> <!-- poi start --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>${poi_version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>${poi_version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>${poi_version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>${poi_version}</version> </dependency> <!-- poi end --> <!-- active mq start --> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.8.0</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-pool</artifactId> <version>${activemq_version}</version> </dependency> <dependency> <groupId>org.apache.xbean</groupId> <artifactId>xbean-spring</artifactId> <version>3.16</version> </dependency> <!-- active mq end --> <!-- servlet start --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>${javax.servlet-api.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- servlet end --> <!-- redis start --> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.7.2</version> </dependency> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson</artifactId> <version>1.0.2</version> </dependency> <!-- redis end --> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <!-- spring conf start --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.6.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.6.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session</artifactId> <version>${spring.session.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <!-- spring conf end --> </dependencies> redis-config.xml [html] view plain copy 在CODE上查看代码片派生到我的代码片 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:/spring/redis.properties" /> <context:component-scan base-package="org.sky.redis"> </context:component-scan> <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host.ip}" /> <property name="port" value="${redis.host.port}" /> <property name="poolConfig" ref="jedisPoolConfig" /> </bean> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="${redis.maxTotal}" /> <property name="maxIdle" value="${redis.maxIdle}" /> <property name="maxWaitMillis" value="${redis.maxWait}" /> <property name="testOnBorrow" value="${redis.testOnBorrow}" /> <property name="testOnReturn" value="${redis.testOnReturn}" /> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"> <property name="connectionFactory" ref="jedisConnectionFactory" /> </bean> <!--将session放入redis --> <bean id="redisHttpSessionConfiguration" class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"> <property name="maxInactiveIntervalInSeconds" value="1800" /> </bean> <bean id="customExceptionHandler" class="sample.MyHandlerExceptionResolver" /> </beans> redis.properties [plain] view plain copy 在CODE上查看代码片派生到我的代码片 redis.host.ip=192.168.0.101 redis.host.port=6379 redis.maxTotal=1000 redis.maxIdle=100 redis.maxWait=2000 redis.testOnBorrow=false redis.testOnReturn=true web.xml [html] view plain copy 在CODE上查看代码片派生到我的代码片 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- - Location of the XML file that defines the root application context - Applied by ContextLoaderListener. --> <!-- tag::context-param[] --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:/spring/redis-conf.xml </param-value> </context-param> <!-- end::context-param[] --> <!-- tag::springSessionRepositoryFilter[] --> <filter> <filter-name>springSessionRepositoryFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSessionRepositoryFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> <!-- end::springSessionRepositoryFilter[] --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/spring/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- - Loads the root application context of this web app at startup. - The application context is then available via - WebApplicationContextUtils.getWebApplicationContext(servletContext). --> <!-- tag::listeners[] --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- end::listeners[] --> <servlet> <servlet-name>sessionServlet</servlet-name> <servlet-class>sample.SessionServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>sessionServlet</servlet-name> <url-pattern>/servlet/session</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 这边主要是一个: [html] view plain copy 在CODE上查看代码片派生到我的代码片 <filter> <filter-name>springSessionRepositoryFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSessionRepositoryFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> 这个filter一定要写在一切filter之前 SessionController [java] view plain copy 在CODE上查看代码片派生到我的代码片 package sample; import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; /** * Created by mk on 15/1/7. */ @Controller @EnableRedisHttpSession public class SessionController { @RequestMapping("/mySession") public String index(final Model model, final HttpServletRequest request) { if (request.getSession().getAttribute("testSession") == null) { System.out.println("session is null"); request.getSession().setAttribute("testSession", "yeah"); } else { System.out.println("not null"); } return "showSession"; } } showSession.jsp文件 [html] view plain copy 在CODE上查看代码片派生到我的代码片 <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>showSession</title> </head> <body> <% String sessionValue=(String)session.getAttribute("testSession"); %> <h1>Session Value From Servlet is: <%=sessionValue%></h1> </body> </html> 测试 保证我们的redise-server是启动的,然后我们启动起这个web工程后使用: http://localhost:8080/webpoc/mySession访问一下这个controller 此时我们使用redis客户端工具连入查看spring session是否已经进入到了redis中去。 在redis客户端工具连入后我们可以在redis console中使用keys *来查看存入的key,LOOK,spring的session存入了redis中去了。 再来看我们的eclipse后台,由于我们是第一次访问这个controller,因此这个session为空,因此它显示如下: 我们在IE中再次访问该controller 由于之前的session已经存在于redis了,因此当用户在1800秒(30分钟)内再次访问controller,它会从session中获取该session的key testSession的值,因此eclipse后台打印为not null。 SpringRedisTemplate + Redis 讲过了spring session+redis我们来讲使用spring data框架提供的redisTemplate来访问redis service吧。说实话,spring这个东西真强,什么都可以集成,cassandra, jms, jdbc...jpa...bla...bla...bla...Spring集成Barack Hussein Obama? LOL :) pom.xml 不用列了,上面有了 redis-conf.xml 不用列了,上面有了 web.xml 也不用列了,上面也有了 SentinelController.java 我们就先用这个名字吧,后面我们会用它来做我们的redis sentinel(哨兵)的高可用(HA)集群测试 [java] view plain copy 在CODE上查看代码片派生到我的代码片 package sample; import java.util.HashMap; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.data.redis.core.BoundHashOperations; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RequestMapping; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisSentinelPool; import util.CountCreater; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; /** * Created by xin on 15/1/7. */ @Controller public class SentinelController { @Autowired private StringRedisTemplate redisTemplate; @RequestMapping("/sentinelTest") public String sentinelTest(final Model model, final HttpServletRequest request, final String action) { return "sentinelTest"; } @ExceptionHandler(value = { java.lang.Exception.class }) @RequestMapping("/setValueToRedis") public String setValueToRedis(final Model model, final HttpServletRequest request, final String action) throws Exception { CountCreater.setCount(); String key = String.valueOf(CountCreater.getCount()); Map mapValue = new HashMap(); for (int i = 0; i < 1000; i++) { mapValue.put(String.valueOf(i), String.valueOf(i)); } try { BoundHashOperations<String, String, String> boundHashOperations = redisTemplate .boundHashOps(key); boundHashOperations.putAll(mapValue); System.out.println("put key into redis"); } catch (Exception e) { e.printStackTrace(); throw new Exception(e); } return "sentinelTest"; } } 打开IE,输入:http://localhost:8080/webpoc/setValueToRedis 观察我们的后台 然后使用redis client连入后进行查看 看。。。这个值key=1的,就是我们通过spring的redisTemplate存入进去的值,即使用下面这段代码进行存入的值: [java] view plain copy 在CODE上查看代码片派生到我的代码片 for (int i = 0; i < 1000; i++) { mapValue.put(String.valueOf(i), String.valueOf(i)); } try { BoundHashOperations<String, String, String> boundHashOperations = redisTemplate.boundHashOps(key); boundHashOperations.putAll(mapValue); 如何你要存入一个简单的如key=test value=hello,你可以这样使用你的redisTemplate [java] view plain copy 在CODE上查看代码片派生到我的代码片 redisTemplate.execute(new RedisCallback<Object>() { @Override public Object doInRedis(RedisConnection connection) throws DataAccessException { connection.set( redisTemplate.getStringSerializer().serialize( "test"), redisTemplate .getStringSerializer() .serialize("hello")); return null; } }); 是不是很方便的哈?结束第一天的教程,明天开始搭建redis集群。
Maalfer / CVE 2023 38831 ReverseShell Winrar RCEPasos necesarios para obtener una reverse shell explotando la vulnerabilidad de winrar CVE-2023-38831 en versiones anteriores a 6.23.
Jackyj09 / Rclone HerokuShellRun Rclone in Telegram bot with Heroku
csabigee / Shell Rcdrive the simple ble rc cars by shell with game controllers
xiaoyin998 / Linux###什么是Linux系统,Linux有哪些部分,Linux都用在了哪些地方? Linux是一套免费使用和自由传播的类Unix操作系统,Linux可安装在各种计算机硬件设备中,比如手机、平板电脑、路由器、视频游戏控制台、台式计算机、大型机和超级计算机。 其创始人为林纳斯·托瓦兹,于1991 年10 月5 日诞生。 系统中的所有都归结为一个文件,包括命令、硬件和软件设备、操作系统、进程等等,Linux是一款免费的操作系统,用户可以通过网络或其他途径免费获得,并可以任意修改其源代码。其完全兼容POSIX1.0标准,这为用户从Windows转到Linux奠定了基础。 Linux支持多用户,各个用户对于自己的文件设备有自己特殊的权利,保证了各用户之间互不影响。多任务则是现在电脑最主要的一个特点,Linux可以使多个程序同时并独立地运行。Linux同时具有字符界面和图形界面。在字符界面用户可以通过键盘输入相应的指令来进行操作。它同时也提供了类似Windows图形界面的X-Window系统,用户可以使用鼠标对其进行操作。 Linux由于其稳定性高、完全免费,目前主要用于服务器市场。 ###Linux和Windows有什么区别,Linux有哪些优势? 其同时具有字符界面和图形界面,开放源代码,用户可以通过网络或其他途径免费获得Linux,并可以任意修改其源代码,这是windows所做不到的。 ###Linux的基本文件(夹)操作命令有哪些? 1.date :设置系统日期和时间。 2. stty -a: 可以查看或者打印控制字符(Ctrl-C, Ctrl-D, Ctrl-Z等) 3. passwd: print or set the system date and time (用passwd -h查看) 4. logout, login: 登录shell的登录和注销命令 5. pwd: 加载目录。 6. more, less, head tail: 显示或部分显示文件内容. 7. lp/lpstat/cancel, lpr/lpq/lprm: 打印文件. 8. 更改文件权限: chmod u+x... 9. 删除非空目录:rm -fr dir 10.拷贝目录: cp -R dir 11. fg jobid :可以将一个后台进程放到前台。 Ctrl-z 可以将前台进程挂起(suspend), 然后可以用bg jobid 让其到后台运行。 job & 可以直接让job直接在后台运行。 12. kill: 向一个进程发送控制信号。 13.卸载: dpkg -r package 14.卸载并删除配置文件: dpkg -P |--purge package 15.安装: dpkg -i package 16. 查看软件包安装内容 :dpkg -L package 17.查看文件由哪个软件包提供: dpkg -S filename 18. 安装: apt-get install packs 19. apt-get update : 更新源 20.apt-get upgrade: 升级系统。 21. apt-get dist-upgrade: 智能升级。安装新软件包,删除废弃的软件包 22. apt-get -f install : -f == --fix broken 修复依赖 23. apt-get autoremove: 自动删除无用的软件 24. apt-get remove packages :删除软件 25. apt-get remove package --purge 删除包并清除配置文件 26. 清除删除包的残余配置文件: dpkg -l |grep ^rc|awk '{print $2}' |tr ["/n"] [" "]|sudo xargs dpkg -P 27.安装软件时候包的临时存放目录 : /var/cache/apt/archives 28. 清除该目录: apt-get clean 29. 清除该目录的旧版本的软件缓存: apt-get autoclean 30. 查询软件some的依赖包: apt-cache depends some 31. 查询软件some被哪些包依赖: apt-get rdepends some 32. 搜索软件: apt-cache search name|regexp 33. 查看软件包的作用:apt-cache show package 34. 查看一个软件的编译依赖库: apt-cache showsrc packagename|grep Build-Depends 35. 下载软件的源代码 : apt-get source packagename (注: sources.list 中应该有 deb-src 源) 36. 安装软件包源码的同时, 安装其编译环境 :apt-get build-dep packagename (有deb-src源) 37.将本地光盘加入安装源列表: apt-cdrom add 38. 查看内核版本: uname -a 39. 查看ubuntu 版本: cat /etc/issue 40. 查看网卡状态 : ethtool eth0 41. 查看内存,cpu的信息: cat /proc/meminfo ; cat /proc/cpuinfo 42. 打印文件系统空间使用情况: df -h 43. 查看硬盘分区情况: fdisk -l 44. 产看文件大小: du -h filename; 45. 查看目录大小: du -hs dirname ; du -h dirname是查看目录下所有文件的大小 46. 查看内存的使用: free -m|-g|-k 47. 查看进程: ps -e 或ps -aux -->显示用户 48. 杀掉进程: kill pid 49. 强制杀掉: killall 等等。 ###什么是开源软件,开源社区有哪些,开源软件有什么优势和劣势? 开源软件即开放源代码软件,其源码可以被公众使用,并且此软件的使用,修改和分发也不受许可证的限制。 开源社区包括开源中国、GoogleCode、GitHub、SourceForge、CodeProject、Apache、ChinaUnix、CodePlex、LUPA、Linux中文社区、51开源社区、Open-Open等。 开源软件优点是免费,代码开放,方便其他程序员编辑;缺点是安全性得不到保障。 ###为什么要有版本控制,git都有哪些操作,和GitHub有什么关系? 版本控制可以保证修改文件或代码时不破坏掉修改前的状态;发布软件的时候很多时候会有多个版本,而生成软件的源代码却往往只有一份,只是在最后编译生成的时候用到不同的部分,大部分代码还是共用的,所以往往需要版本控制,几个版本复制几个文件夹出来。 git update-index –-skip-worktree [file] 可以实现修改本地文件不会被提交,但又可以拉取最新更改的需求。 git update-index --no-assume-unchanged重新跟踪 pretty=oneline 每个提交日志信息只显示一行 git checkout – readme.txt把readme.txt文件在工作区的修改全部撤销 git reset HEAD readme.txt把暂存区的修改撤销掉,重新放回工作区 git checkout – readme.txt撤销修改,也就是回到版本库的状态 git remote add origin 远程版本库URL:git push -u origin master把本地的master分支和远程的master分支关联起来 git log --graph 命令可以看到分支合并图 等等。 git是软件,它可在本地建立仓库,你写的代码的各个版本都可以存储,github是网上仓库,你写的代码的各个版本都可以存储。 Tom之所以把网站叫做Github,是因为其核心部分版本控制是用Git来处理的。gitHub是一个面向开源及私有软件项目的托管平台, 因为只支持git 作为唯一的版本库格式进行托管,故名gitHub。 ###ARM架构处理器都有哪些,有什么特点,处理器的结构都有哪些,有哪些特点? ARMv7架构的Cortex-A5,A7,A8,A9,A12,A15,ARMv8架构的Cortex-A53,A57,A72。 1、体积小、低功耗、低成本、高性能; 2、支持Thumb(16位)/ARM(32位)双指令集,能很好的兼容8位/16位器件; 3、大量使用寄存器,指令执行速度更快; 4、大多数数据操作都在寄存器中完成; 5、寻址方式灵活简单,执行效率高; 6、指令长度固定。 CPU从逻辑上可以划分成3个模块,分别是控制单元、运算单元和存储单元。逻辑单元包括指令寄存器、指令译码器、控制单元、寄存器、逻辑运算单元(ALU)、预取单元、总线单元、数据高速缓存。 AMD的CPU特点是核心数量多,单核性能低,功耗比较高,性价比比较高;英特尔的CPU的特点是,核心数量少,单核性能强,所以对于绝大多数游戏来说都比AMD的表现要好,功耗低,发热低,比较主流。 ###为什么在路由器中可以安装Linux,在路由器中使用的Linux和在桌面端使用的有什么区别? Linux支持路由器功能,如OpenWrt、LEDE,都是基于Linux的路由器系统。 ###为什么要有操作系统? 操作系统是一种驱动程序。让人们不需要关心一些硬件细节,就可以使用硬件。 可享使用硬件资源;为使用者指定一些规范,让不同的使用者可以共享使用硬件。 操作系统就是为了让人们更加方便的使用硬件资源的一个工具,让我们更好地使用硬件资源各种硬件资源。 ###自己对计算机分层思想的理解。 分层思想主要就是将一个复杂的计算机网络分开管理,各个层实行相应的功能,便于管理,和标准的实行。分层思想是一种模块化设计,总的来说就是为了方便。 ###UART串口通信的层次结构是怎样的? 起始位:先发一个逻辑“0”信号,表示传输的开始 数据位:紧接着起始位,从低位开始传动,发送速率靠时钟确定 停止位:数据位加上这一为使得“1”的位数为偶数(偶校验)或奇数(奇校验),以此来校验数据的正确性 停止位:一个字符数据的结束标 空闲位:处于逻辑“1”状态,表示当前线路没有数据传输。 ###为什么Qt可以跨平台使用而VS不能,C语言的编译步骤是怎样的,常用的编译器有哪些? 针对每一种OS平台,QT都有一套对应的底层类库,而接口是完全一致的,因此只要是在QT库上开发的程序,放在任何一种平台下都可以编译运行。 【第一步】编辑hello.c 1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 printf("hello world!\n"); 6 return 0; 7 } 【第二步】预处理 预处理过程实质上是处理“#”,将#include包含的头文件直接拷贝到hell.c当中;将#define定义的宏进行替换,同时将代码中没用的注释部分删除等。 (1)将所有的#define删除,并且展开所有的宏定义。说白了就是字符替换 (2)处理所有的条件编译指令,#ifdef #ifndef #endif等,就是带#的那些 (3)处理#include,将#include指向的文件插入到该行处 (4)删除所有注释 (5)添加行号和文件标示,这样的在调试和编译出错的时候才知道是是哪个文件的哪一行 (6)保留#pragma编译器指令,因为编译器需要使用它们。 【第三步】编译 (1)词法分析, (2)语法分析 (3)语义分析 (4)优化后生成相应的汇编代码 【第四步】链接 常用的编译器: Cygwin、Mingw32、DJGPP、Dev-C++、GNU C++、MSC 5.0、6.0、7.0、MSQC 1.0、2.5、MSVC 1.0、4.2、6.0、7.0、Visual C++等等。 ###C语言中主函数的返回值可以返回什么东西,主函数的参数又是如何确定的? main函数的返回值用于说明程序的退出状态。如果返回0,则代表程序正常退出。返回其它数字的含义则由系统决定。通常,返回非零代表程序异常退出。返回值为1的时候则代表程序运行遇到问题失败。 主函数的第一个参数是一个整数,它表示第二个参数里的指针个数,主函数的第二个参数是一个字符指针数组,其中每个指针代表一个字符串,所有这些字符串的内容都来自于用户的命令。 argc是命令行总的参数个数,argv[]是argc个参数,其中第0个参数是程序的全名,以后的参数命令行后面跟的用户输入的参数,char *argv[]是一个字符数组,其大小是int argc,主要用于命令行参数, char*envp[]用来取得系统的环境变量。
mrhmouse / Rc Mode.elEmacs major mode for the Plan9 rc shell
Nailim / Plan9 RchistoryAn attempt to bring command history trough keyboard shortcuts to rc shell inside rio window following the philosophy of modularity.
adigeentz / Sshcentos6#!/bin/bash # initialisasi var OS=`uname -m`; MYIP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | grep -v '127.0.0.2'`; MYIP2="s/xxxxxxxxx/$MYIP/g"; # go to root cd # set locale sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config service sshd restart # disable ipv6 echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.d/rc.local # install wget and curl yum -y install wget curl # setting repo wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm rpm -Uvh epel-release-6-8.noarch.rpm rpm -Uvh remi-release-6.rpm if [ "$OS" == "x86_64" ]; then wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm else wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.i686.rpm fi sed -i 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo sed -i -e "/^\[remi\]/,/^\[.*\]/ s|^\(enabled[ \t]*=[ \t]*0\\)|enabled=1|" /etc/yum.repos.d/remi.repo rm -f *.rpm # remove unused yum -y remove sendmail; yum -y remove httpd; yum -y remove cyrus-sasl # update yum -y update # install webserver yum -y install nginx php-fpm php-cli service nginx restart service php-fpm restart chkconfig nginx on chkconfig php-fpm on # install essential package yum -y install rrdtool screen iftop htop nmap bc nethogs openvpn vnstat ngrep mtr git zsh mrtg unrar rsyslog rkhunter mrtg net-snmp net-snmp-utils expect nano bind-utils yum -y groupinstall 'Development Tools' yum -y install cmake yum -y --enablerepo=rpmforge install axel sslh ptunnel unrar # matiin exim service exim stop chkconfig exim off # setting vnstat vnstat -u -i venet0 echo "MAILTO=root" > /etc/cron.d/vnstat echo "*/5 * * * * root /usr/sbin/vnstat.cron" >> /etc/cron.d/vnstat sed -i 's/eth0/venet0/g' /etc/sysconfig/vnstat service vnstat restart chkconfig vnstat on # install screenfetch cd wget https://github.com/KittyKatt/screenFetch/raw/master/screenfetch-dev mv screenfetch-dev /usr/bin/screenfetch chmod +x /usr/bin/screenfetch echo "clear" >> .bash_profile echo "screenfetch" >> .bash_profile # install webserver cd wget -O /etc/nginx/nginx.conf "https://raw.github.com/arieonline/autoscript/master/conf/nginx.conf" sed -i 's/www-data/nginx/g' /etc/nginx/nginx.conf mkdir -p /home/vps/public_html echo "<pre>Setup by KangArie | JualSSH.com | @arieonline | 7946F434</pre>" > /home/vps/public_html/index.html echo "<?php phpinfo(); ?>" > /home/vps/public_html/info.php rm /etc/nginx/conf.d/* wget -O /etc/nginx/conf.d/vps.conf "https://raw.github.com/arieonline/autoscript/master/conf/vps.conf" sed -i 's/apache/nginx/g' /etc/php-fpm.d/www.conf chmod -R +rx /home/vps service php-fpm restart service nginx restart # install openvpn wget -O /etc/openvpn/openvpn.tar "https://raw.github.com/arieonline/autoscript/master/conf/openvpn-debian.tar" cd /etc/openvpn/ tar xf openvpn.tar wget -O /etc/openvpn/1194.conf "https://raw.github.com/arieonline/autoscript/master/conf/1194-centos.conf" if [ "$OS" == "x86_64" ]; then wget -O /etc/openvpn/1194.conf "https://raw.github.com/arieonline/autoscript/master/conf/1194-centos64.conf" fi wget -O /etc/iptables.up.rules "https://raw.github.com/arieonline/autoscript/master/conf/iptables.up.rules" sed -i '$ i\iptables-restore < /etc/iptables.up.rules' /etc/rc.local sed -i '$ i\iptables-restore < /etc/iptables.up.rules' /etc/rc.d/rc.local sed -i $MYIP2 /etc/iptables.up.rules; iptables-restore < /etc/iptables.up.rules sysctl -w net.ipv4.ip_forward=1 sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf service openvpn restart chkconfig openvpn on cd # configure openvpn client config cd /etc/openvpn/ wget -O /etc/openvpn/1194-client.ovpn "https://raw.github.com/arieonline/autoscript/master/conf/1194-client.conf" sed -i $MYIP2 /etc/openvpn/1194-client.ovpn; PASS=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n 1`; useradd -M -s /bin/false KangArie echo "KangArie:$PASS" | chpasswd echo "username" > pass.txt echo "password" >> pass.txt tar cf client.tar 1194-client.ovpn pass.txt cp client.tar /home/vps/public_html/ cd # install badvpn wget -O /usr/bin/badvpn-udpgw "https://raw.github.com/arieonline/autoscript/master/conf/badvpn-udpgw" if [ "$OS" == "x86_64" ]; then wget -O /usr/bin/badvpn-udpgw "https://raw.github.com/arieonline/autoscript/master/conf/badvpn-udpgw64" fi sed -i '$ i\screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300' /etc/rc.local sed -i '$ i\screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300' /etc/rc.d/rc.local chmod +x /usr/bin/badvpn-udpgw screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 # install mrtg cd /etc/snmp/ wget -O /etc/snmp/snmpd.conf "https://raw.github.com/arieonline/autoscript/master/conf/snmpd.conf" wget -O /root/mrtg-mem.sh "https://raw.github.com/arieonline/autoscript/master/conf/mrtg-mem.sh" chmod +x /root/mrtg-mem.sh service snmpd restart chkconfig snmpd on snmpwalk -v 1 -c public localhost | tail mkdir -p /home/vps/public_html/mrtg cfgmaker --zero-speed 100000000 --global 'WorkDir: /home/vps/public_html/mrtg' --output /etc/mrtg/mrtg.cfg public@localhost curl "https://raw.github.com/arieonline/autoscript/master/conf/mrtg.conf" >> /etc/mrtg/mrtg.cfg sed -i 's/WorkDir: \/var\/www\/mrtg/# WorkDir: \/var\/www\/mrtg/g' /etc/mrtg/mrtg.cfg sed -i 's/# Options\[_\]: growright, bits/Options\[_\]: growright/g' /etc/mrtg/mrtg.cfg indexmaker --output=/home/vps/public_html/mrtg/index.html /etc/mrtg/mrtg.cfg echo "0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" > /etc/cron.d/mrtg LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg cd # setting port ssh sed -i '/Port 22/a Port 143' /etc/ssh/sshd_config sed -i 's/#Port 22/Port 22/g' /etc/ssh/sshd_config service sshd restart chkconfig sshd on # install dropbear yum -y install dropbear echo "OPTIONS=\"-p 109 -p 110 -p 443\"" > /etc/sysconfig/dropbear echo "/bin/false" >> /etc/shells service dropbear restart chkconfig dropbear on # install vnstat gui cd /home/vps/public_html/ wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz tar xf vnstat_php_frontend-1.5.1.tar.gz rm vnstat_php_frontend-1.5.1.tar.gz mv vnstat_php_frontend-1.5.1 vnstat cd vnstat sed -i 's/eth0/venet0/g' config.php sed -i "s/\$iface_list = array('venet0', 'sixxs');/\$iface_list = array('venet0');/g" config.php sed -i "s/\$language = 'nl';/\$language = 'en';/g" config.php sed -i 's/Internal/Internet/g' config.php sed -i '/SixXS IPv6/d' config.php cd # install fail2ban yum -y install fail2ban service fail2ban restart chkconfig fail2ban on # install squid yum -y install squid wget -O /etc/squid/squid.conf "https://raw.github.com/arieonline/autoscript/master/conf/squid-centos.conf" sed -i $MYIP2 /etc/squid/squid.conf; service squid restart chkconfig squid on # install webmin cd wget http://prdownloads.sourceforge.net/webadmin/webmin-1.670-1.noarch.rpm rpm -i webmin-1.670-1.noarch.rpm; rm webmin-1.670-1.noarch.rpm service webmin restart chkconfig webmin on # pasang bmon if [ "$OS" == "x86_64" ]; then wget -O /usr/bin/bmon "https://raw.github.com/arieonline/autoscript/master/conf/bmon64" else wget -O /usr/bin/bmon "https://raw.github.com/arieonline/autoscript/master/conf/bmon" fi chmod +x /usr/bin/bmon # downlaod script cd wget -O speedtest_cli.py "https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py" wget -O bench-network.sh "https://raw.github.com/arieonline/autoscript/master/conf/bench-network.sh" wget -O ps_mem.py "https://raw.github.com/pixelb/ps_mem/master/ps_mem.py" wget -O limit.sh "https://raw.github.com/arieonline/autoscript/master/conf/limit.sh" curl http://script.jualssh.com/user-login.sh > user-login.sh curl http://script.jualssh.com/user-expire.sh > user-expire.sh curl http://script.jualssh.com/user-limit.sh > user-limit.sh echo "0 0 * * * root /root/user-expire.sh" > /etc/cron.d/user-expire sed -i '$ i\screen -AmdS limit /root/limit.sh' /etc/rc.local sed -i '$ i\screen -AmdS limit /root/limit.sh' /etc/rc.d/rc.local chmod +x bench-network.sh chmod +x speedtest_cli.py chmod +x ps_mem.py chmod +x user-login.sh chmod +x user-expire.sh chmod +x user-limit.sh chmod +x limit.sh # cron service crond start chkconfig crond on # set time GMT +7 ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime # finalisasi chown -R nginx:nginx /home/vps/public_html service nginx start service php-fpm start service vnstat restart service openvpn restart service snmpd restart service sshd restart service dropbear restart service fail2ban restart service squid restart service webmin restart service crond start chkconfig crond on # info clear echo "JualSSH.com | @arieonline | KangArie | 7946F434" | tee log-install.txt echo "===============================================" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "Service" | tee -a log-install.txt echo "-------" | tee -a log-install.txt echo "OpenVPN : TCP 1194 (client config : http://$MYIP/client.tar)" | tee -a log-install.txt echo "OpenSSH : 22, 143" | tee -a log-install.txt echo "Dropbear : 109, 110, 443" | tee -a log-install.txt echo "Squid3 : 8080 (limit to IP SSH)" | tee -a log-install.txt echo "badvpn : badvpn-udpgw port 7300" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "Tools" | tee -a log-install.txt echo "-----" | tee -a log-install.txt echo "axel" | tee -a log-install.txt echo "bmon" | tee -a log-install.txt echo "htop" | tee -a log-install.txt echo "iftop" | tee -a log-install.txt echo "mtr" | tee -a log-install.txt echo "nethogs" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "Script" | tee -a log-install.txt echo "------" | tee -a log-install.txt echo "screenfetch" | tee -a log-install.txt echo "./ps_mem.py" | tee -a log-install.txt echo "./speedtest_cli.py --share" | tee -a log-install.txt echo "./bench-network.sh" | tee -a log-install.txt echo "./user-login.sh" | tee -a log-install.txt echo "./user-expire.sh" | tee -a log-install.txt echo "./user-limit.sh 2" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "Account Default (utk SSH dan VPN)" | tee -a log-install.txt echo "---------------" | tee -a log-install.txt echo "User : KangArie" | tee -a log-install.txt echo "Password : $PASS" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "Fitur lain" | tee -a log-install.txt echo "----------" | tee -a log-install.txt echo "Webmin : http://$MYIP:10000/" | tee -a log-install.txt echo "vnstat : http://$MYIP/vnstat/" | tee -a log-install.txt echo "MRTG : http://$MYIP/mrtg/" | tee -a log-install.txt echo "Timezone : Asia/Jakarta" | tee -a log-install.txt echo "Fail2Ban : [on]" | tee -a log-install.txt echo "IPv6 : [off]" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "Log Installasi --> /root/log-install.txt" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "SILAHKAN REBOOT VPS ANDA !" | tee -a log-install.txt echo "" | tee -a log-install.txt echo "===============================================" | tee -a log-install.txt
weakish / Rcshell.vimsyntax highlight file for the rc shell scripting language
dancrossnyc / LibprintModernized version of libprint extracted from Byron's rc shell.