Sunday, December 1, 2013

A $45 Linux SSD Laptop from China

Last week a Chinese computer company sell a laptop with $45.

There is some english information about the laptop.

Lemote ultra mini-laptop is powered by the latest design-by-China 64-bit Loongson-2F processor which speeds at 900MHz.The integrated DDR 2 and PCI 2 controllers and independently designed Northbridge chipsets.

Product characteristics:

  1. Strong computing:
    It employs the latest Loongson-2F processor, 64-bit, four-issue Out-Of-Order structure and integrated memory controller.
  2. Energy saving and environmental friendly:
    Less than 20 W, which is one tenth of an ordinary PC. The materials are ROHS compliant.
  3. Quiet operation:
    Less than 60 db.
  4. security:
    Yeeloong 8089 is a safe computing device. On one hand, the hardware components including chipset and matching motherboard are designed by Lemote wholly, which lowers the risico's being intruded by various viruses. On another hand, by employing GNU Linux operating system, it is almost immune to viruses.
  5. Infinite customization:
    The unique programmable Northbridge provides space for customization; the operation and application of free operating system could adopt a free open-source software (FOSS), which is a powerful software package management mechanism that provides the most convenient methods for users' customization and development demands to exempt from getting into the trouble of software copyright.
  6. low cost:
    The entire product, including processor, system, software and so on, are all designed by Lemote. The cost for software, hardware and synthesized usage cost is only of an ordinary PC.

Specifications

  • Processor: Loongson 2F CPU, 900MGHz, integrated DDR II and PCI 2 controllers;
  • Memory slots: SO-DIMM DDR2, 512MB;
  • South bridge: AMD CS5536;
  • Display: 1024 x 600, 8,9" TFT LCD;
  • Network: Rtl8139 + RTL8187B(wifi);
  • Interface: USB2.0x3, earphone+MIC, SDx1, RJ45x1, VGAx1, DC-inx1; SD reader supports SDHC.
  • Storage: 8G SSD;
  • Graphics: SMI712
  • Webcam: Webcam with 300K pixel
  • SD: Realtek RTS5158E
  • Size: 25,2 x 3 x 18,5cm
  • Weight: 1 kg 
  • Operating Systems: Debian Linux; Loonux; Red Flag Linux;
  • Full power: less than 20 W;
  • USB: 2 x USBBattery: 3 Cell Lithium.

Application field

It could be used as ordinary laptop as well as professional computing device for users who have higher demand for security and software customization such as institutions, prototype product development, government, corporate R & D, high education, financial and security organizations etc.

Tuesday, October 29, 2013

How to Empty Postfix Mail Queue

mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "email@address.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d - sudo postsuper -d ALL ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'}L

Monday, October 28, 2013

Saturday, October 5, 2013

How to count mail on queue

sudo find /var/spool/postfix/deferred/. ! -name . ! -name '?' -print | wc -l

Monday, July 8, 2013

Sending and Receiving Data use Java socket programming

//java socket client example
import java.io.*;
import java.net.*;

public class socket_client
{
    public static void main(String[] args) throws IOException
    {
        Socket s = new Socket();
    String host = "dev.easy-conn.com";
    PrintWriter s_out = null;
    BufferedReader s_in = null;
       
        try
        {
        s.connect(new InetSocketAddress(host , 6557));
        System.out.println("Connected");
           
        //writer for socket
            s_out = new PrintWriter( s.getOutputStream(), true);
            //reader for socket
            s_in = new BufferedReader(new InputStreamReader(s.getInputStream()));
        }
       
        //Host not found
        catch (UnknownHostException e)
        {
            System.err.println("Don't know about host : " + host);
            System.exit(1);
        }
       
        //Send message to server
    String message = "GET hosts\r\n\r\n";
    s_out.println( message );
           
    System.out.println("Message send");
       
    //Get response from server
    String response;
    while ((response = s_in.readLine()) != null)
    {
        System.out.println( response );
    }
    }
}

Thursday, July 4, 2013

Bind livestatus unix socket to TCP socket use Python and twisted

from twisted.internet import protocol, reactor
import socket,os

socket_path = "/var/lib/nagios3/rw/live"

class Echo(protocol.Protocol):
    def dataReceived(self, data):
 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

 s.connect(socket_path)

 s.send(data)
 s.shutdown(socket.SHUT_WR)
 answer = s.recv(100000000)
        self.transport.write(answer)

class EchoFactory(protocol.Factory):
    def buildProtocol(self, addr):
        return Echo()

reactor.listenTCP(6557, EchoFactory())
reactor.run()

Monday, July 1, 2013

One liner to download Oracle JDK with wget

wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk-7u17-download-1501626.html;" http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-i586.tar.gz --no-check-certificate -O jdk-7u25-linux-i586.tar.gz

Sunday, June 30, 2013

Create a read only monitor user to Oracle database

需要 SYSDBA 权限。
CREATE USER nagios IDENTIFIED BY oradbmon; 
GRANT CREATE SESSION TO nagios;
GRANT SELECT any dictionary TO nagios;
GRANT SELECT ON V_$SYSSTAT TO nagios;
GRANT SELECT ON V_$INSTANCE TO nagios;
GRANT SELECT ON V_$LOG TO nagios;
GRANT SELECT ON SYS.DBA_DATA_FILES TO nagios;
GRANT SELECT ON SYS.DBA_FREE_SPACE TO nagios;

Thursday, April 4, 2013

Puma and rails to auto start on Linux rc.local

su ubuntu -c 'source /etc/profile && cd /home/ubuntu/downloads/redmine-2.1/ && NEWRELIC_ENABLE=true rails s Puma -e production -p 8080 -d'

Sunday, January 13, 2013

安装obfuscated反制gfw对ssh连接的干扰

看到所用的ssh代理服务供应商开始在server上部署和测试Obfuscation功能,以抵御某怪物干扰用户正常使用ssh代理。

1. 原理


以下是ISP提供的说明:

那何为Obfuscation?
查了下Wikipedia:
In cryptography, obfuscation refers to encoding the input data before it is sent to
a hash function or other encryption scheme. This technique helps to make brute force
attacks unfeasible, as it is difficult to determine the correct cleartext.

从密码学角度上讲,Obfuscation(混淆)指的是在将所输入的数据发送至哈希公式或者其他加密公式
前对其进行编码,该技术使得暴利破解难以见效,因为要确认正确的明文非常困难。

概念蛮绕口的,实际上就是将handshake易容,这样怪物就看不出来数据传输是在使用ssh协议了.

2. 解决方案


牛人Bruce Leidl为openssh写了个很给力的补丁。它可以在创建加密SSH连接时将握手信号(handshake)进行混淆处理。这样一个加密的握手信号就可以骗过怪物所用的深度包检测设备,顺利完成使命,进而保证了网络的安全性与稳定性。

(1)准备


你需要有一台位于境外的Linux服务器,然后在服务器上配置好Obfuscated-openssh补丁。
Obfuscated-openssh点此下载: http://socks.nihilex.com/brl-obfuscated-openssh-7288432890c63dc228afe6c61e6343b72ef30962.tar.gz,然后执行下述命令编译安装:

./configure
make
make install


建议将其与常规的SSH守护进程分开安装。

(2)配置


作为SSH代理的话,没有必要让用户通过ssh登陆服务器,因此需要将此部分权限给限制掉,让用户只能使用SOCKS代理。要做到这点,需要创建专用的用户账号。

以下即为添加一个名为“golengssh"用户的命令,该用户无法远程登入服务器:

useradd -s /usr/sbin/nologin golengssh

下面为大家提供一个sshd_config文件供参考使用,使用此配置文件后,只允许用户“golengssh”连接服务器。

Linux桌面系统下,连接服务器的命令是:

ssh -Nfx -D 7070 -Z yuanjin golengssh@ur-host.com -p 443

这里的“yuanjin”就是在配置文件中的ObfuscateKeyword,ssh的服务器端口为443,最后设置浏览器的SOCKS代理为127.0.0.1:7070

SSHD_config

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
#
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

# This ssh daemon is meant to be run separately from the regular
# non-obfuscated sshd. A single user account is enough for this purpose.
# You should make sure this user does not have shell access, by changing
# the shell to /usr/sbin/nologin.
# sudo useradd -s /usr/sbin/nologin golengssh
#
AllowUsers golengssh

# To set up a SOCKS proxy, execute an obfuscated-openssh client like so:
# The client will now be running a SOCKS proxy on localhost:7070 and forwarding
# all traffic to the ssh server port 443. User will need to configure web browsers and
# such to use the SOCKS proxy.
#
Protocol 2
ObfuscatedPort 443
ObfuscateKeyword yuanjin
#Port 22

SyslogFacility AUTH
LogLevel ERROR
LoginGraceTime 2m
PermitRootLogin no
StrictModes yes
MaxAuthTries 6
MaxSessions 10
PermitEmptyPasswords no

AllowAgentForwarding no
AllowTcpForwarding yes
PrintLastLog no
TCPKeepAlive yes
ClientAliveInterval 60
ClientAliveCountMax 3
PidFile /var/run/obf_sshd.pid
#MaxStartups 10
#PermitTunnel no
ChrootDirectory /home/golengssh

# no default banner path
#Banner none


参考文章:
[1]Secret Handshake for Iran http://nihilex.com/obfuscated-openssh
[2]Obfuscation http://en.wikipedia.org/wiki/Obfuscation
------------------------------------------------

中国防火长城测试对加密链接神秘扫描


在中国的审查机器和互联网用户的猫捉老鼠的游戏中,政府看来正在测试一种新的“捕鼠器”了——它被设计为通过防火长城探测并封锁加密通道,哪怕这种通道连接的是鲜为人知的计算机,并已经过加密。
最近几个月,本来设计了通过加密连接服务让用户安全地连接到远程计算机的管理员们观察到来自中国大陆的奇怪网络活动:当一个国内用户试图登录国外服务器时,在他/她连接到该网站之前,一串看似随机的数据已经先抵达目的地,有时这个用户的连接接着就神秘地被切断了。
例如,反审查和匿名服务提供商Tor就发现许多他们的“网桥节点”——用来帮助用户重定路由的位于世界各地的私人服务器——对中国用户来说,在几个 小时内甚至几分钟内就失效了。Tor项目的执行主任安德鲁‧鲁曼(Andrew Lewman)说用户告诉他,其他翻墙软件如无界浏览(Ultrasurf)和自由门(Freegate)也出现了类似的问题。“有人试图接入,接着出现 一个奇怪的扫瞄,然后节点就失效了,”鲁曼说:“我们经常观察到奇怪的现象,但这个却是个不平衡的怪现象,而且只来自于中国。”
鲁曼认为中国互联网服务公司可能正在测试一个新系统,不仅仅是阻挡IP地址或者某些网页,而是通过一个类似探头的东西在用户试图连接到加密网络之前 确认用户要接入什么服务。“就好像我告诉太太要和朋友去打保龄球,她事先给保龄球馆打电话来监视我到底在干什么,”鲁曼这样比喻道。“它在证实你要访问的 是不是你正在请求访问的地址。”
但是鲁曼说Tor程序开发员们目前还无法确定这个探头如何能区分用户是在加密登入Tor服务器还是加密登入某银行或电子商务网站,因为理论上两者都 是把网络信息流打乱成无法辨认的加密信息。鲁曼指出:无论如何中国政府无法阻挡所有的加密连接,比如大公司的虚拟专用网(VPN),“如果富士康和苹果断 了线,那可就是大问题了。”
同时,只有一小部分Tor的中国用户遇到这个问题,鲁曼说这意味着可能只有部分中国宽带网络公司在试验这个工具。
中共政府不止嗅探通往美国的加密连接,据位于林雪平大学中心(Linkoping University)的瑞典国家超级计算机中心的IT安全管理员列夫‧尼克松(Leif Nixon)说,他一年之前就在其服务器上独立地发现了这个现象——当中国学生或研究人员试图通过SSH加密隧道登录该中心的系统时会引来奇怪的网络扫 瞄。本月初他将自己的发现贴在了博客上。
“我不知道这个(数据)探头想达到什么目的,”他这样写道:“我只能猜是那个政府在寻找一些它不认可的服务,如开放代理或者Tor中继服务。如果留下精确指纹代价太大,于是他们就采取类似模糊测试的调查方法,即向服务器扔一段随机数据,看看有什么反应。”
“这也符合中国政府强加给其公民的人尽皆知的审查制度的所作所为,”他补充道:“我极端厌恶这种看似是中国政府在探测我们系统的行为。”
另一位要求不透露姓名的美国计算机安全工程师说,他观察到有20%来自中国用户的连接遭遇这种异常行为。“我们起初以为这是一种攻击行为。但是现在它更像是在探测这些是不是它要过滤的信息,"这位工程师说:"我还从来没有见过类似的东西。”
自从建国60大庆和与谷歌公开翻脸以来,中共一直在追捕翻墙工具。但是鲁曼指出,中国先前的过滤系统都是以阻挡IP地址为基础的,而世界各地不断有新的服务器以新IP地址来帮助中国民众绕开防火长城。
2009年伊朗政府也曾试图从各种加密信息流中鉴别接入Tor网桥节点的连接,鲁曼说,Tor想方设法让它的加密连接看起来更像其他网络服务,例如调整Tor的SSL认证的频率。
鲁曼不认为中国政府会在全国、针对数亿网民实施这个探测系统,但表示Tor工作人员希望永远领先于中共网络监控之前,“我们正在想办法,”他说:“这很令人好奇。"

Sunday, January 6, 2013

Vagrant VirtualBox 下Nginx, Apache编辑CSS文件后乱码

原因:

VirtualBox’s Shared Folders 对 sendfile() 支持不完善

解决方法:

pache:
EnableSendfile off
NGINX:
sendfile off;

什么是 sendfile()