Thursday, July 30, 2015

linux shell: convert epoch time to datetime format

[root@logserver proxy]# date -d @1438240254 "+%F %T"
2015-07-30 10:10:54


python: reading fifo example


fifo - first-in first-out special file, named pipe

A FIFO special file (a named pipe) is similar to a pipe, except that
       it is accessed as part of the filesystem.  It can be opened by
       multiple processes for reading or writing.  When processes are
       exchanging data via the FIFO, the kernel passes all data internally
       without writing it to the filesystem.  Thus, the FIFO special file
       has no contents on the filesystem; the filesystem entry merely serves
       as a reference point so that processes can access the pipe using a
       name in the filesystem.

SEE ALSO  




fifo reader code:

#!/usr/bin/python


__author__ = "Ali Okan Yuksel <okan@siyahsapka.org>"

import sys



def main():
        print "INFO application started"
        fifo="okantest.fifo"
        fd=open(fifo,"r")
        while True:
                line = fd.readline()
                if line !="":
                        sys.stdout.write(line)


if __name__=="__main__":
        main()


data sender bash call:

[root@logserver ~]# for i in `seq 1 1000`; do echo $i > /opt/proxy/okantest.fifo ; done

linux: sudo ile yetkilendirme

sudo komutu ile sadece belirli bir komutun web uzerinden root yetkisi ile tetiklenmesi icin ihtiyac duymustum.

# cat /etc/sudoers.d/apache
apache        ALL=(ALL)       NOPASSWD: /opt/build/wwwroot/build.sh


Friday, July 24, 2015

netcat ile bağlantı testleri

Netcat is a featured networking utility which reads and writes data across network connections, using the TCP/IP protocol.

It is designed to be a reliable "back-end" tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built-in capabilities.

TCP server:
# nc -k -l 23

UDP server:
# nc -k -u -l 23

TCP client:
# nc -w0 172.16.41.82 23 <<< "tcp client example"

UDP client:
# nc -w0 -u 172.16.41.82 23 <<< "udp client example"

-w:  timeout
-k:
-l: listen

 Syntax

nc [-46bCDdhklnrStUuvZz] [-I length] [-i interval] [-O length]
   [-P proxy_username] [-p source_port] [-q seconds] [-s source]
   [-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
   [-x proxy_address[:port]] [destination] [port]

Options


-4    Forces nc to use IPv4 addresses only.
-6    Forces nc to use IPv6 addresses only.
-b    Allow broadcast.
-C    Send CRLF as line-ending.
-D    Enable debugging on the socket.
-d    Do not attempt to read from stdin.
-h    Prints out nc help.
-I length    Specifies the size of the TCP receive buffer.
-i interval    Specifies a delay time interval between lines of text sent and received. Also causes a delay time between connections to multiple ports.
-k    Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option.
-l    Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p, -s, or -z options. Additionally, any timeouts specified with the -w option are ignored.
-n    Do not do any DNS or service lookups on any specified addresses, hostnames or ports.
-O length    Specifies the size of the TCP send buffer.
-P proxy_username    Specifies a username to present to a proxy server that requires authentication. If no username is specified then authentication will not be attempted. Proxy authentication is only supported for HTTP CONNECT proxies at present.
-p source_port    Specifies the source port nc should use, subject to privilege restrictions and availability.
-q seconds    after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever.
-r    Specifies that source and/or destination ports should be chosen randomly instead of sequentially within a range or in the order that the system assigns them.
-S    Enables the RFC 2385 TCP MD5 signature option.
-s source    Specifies the IP of the interface which is used to send the packets. For UNIX-domain datagram sockets, specifies the local temporary socket file to create and use so that datagrams can be received. It is an error to use this option in conjunction with the -l option.
-T toskeyword    Change IPv4 TOS value. toskeyword may be one of critical, inetcontrol, lowcost, lowdelay, netcontrol, throughput, reliability, or one of the DiffServ Code Points: ef, af11 ... af43, cs0 ... cs7; or a number in either hex or decimal.
-t    Causes nc to send RFC 854 DON'T and WON'T responses to RFC 854 DO and WILL requests. This makes it possible to use nc to script telnet sessions.
-U    Specifies to use UNIX-domain sockets.
-u    Use UDP instead of the default option of TCP. For UNIX-domain sockets, use a datagram socket instead of a stream socket. If a UNIX-domain socket is used, a temporary receiving socket is created in /tmp unless the -s flag is given.
-V rtable    Set the routing table to be used. The default is 0.
-v    Have nc give more verbose output.
-w timeout    Connections which cannot be established or are idle timeout after timeout seconds. The -w flag has no effect on the -l option, i.e. nc will listen forever for a connection, with or without the -w flag. The default is no timeout.
-X proxy_protocol    Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are "4" (SOCKS v.4), "5" (SOCKS v.5) and "connect" (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.
-x proxy_address[:port]    Requests that nc should connect to destination using a proxy at proxy_address and port. If port is not specified, the well-known port for the proxy protocol is used (1080 for SOCKS, 3128 for HTTPS).
-Z    DCCP mode.
-z    Specifies that nc should just scan for listening daemons, without sending any data to them. It is an error to use this option in conjunction with the -l option.

iphone: Illegal instruction: 4 hatası

jailbroken iphone device:

iPhone:/ root# ./usr/bin/aSMS
Illegal instruction: 4

iPhone:/ root# sed -i'' 's/\x00\x30\x93\xe4/\x00\x30\x93\xe5/g;s/\x00\x30\xd3\xe4/\x00\x30\xd3\xe5/g;' ./usr/bin/aSMS

iPhone:/ root# ldid -s ./usr/bin/aSMS
ldid.cpp(1205): _assert(signature != NULL); errno=0

iPhone:/ root# /usr/bin/aSMS
1437721353 set_ssl: cannot load libssl.0.9.7.dylib

iPhone:/ root# ls /usr/lib/libssl.*
/usr/lib/libssl.0.9.8.dylib  /usr/lib/libssl.dylib

iPhone:/ root# ln -s /usr/lib/libssl.0.9.8.dylib /usr/lib/libssl.0.9.7.dylib

iPhone:/ root# /usr/bin/aSMS
iPhone:/ root# launchctl load -w /Library/LaunchDaemons/com.googlecode.aSMS.plist

Tuesday, July 7, 2015

"hacking team" hacked

Someone hacked the cyberweapons arms manufacturer Hacking Team and posted 400 GB of internal company data.

Hacking Team is a pretty sleazy company, selling surveillance software to all sorts of authoritarian governments around the world. Reporters Without Borders calls it one of the enemies of the Internet. Citizen Lab has published many reports about their activities.
...
Source: https://www.schneier.com/blog/archives/2015/07/hacking_team_is.html

Slashdot thread. Hacker News thread.

Tixati bittorrent client http://www.tixati.com/