[20171225]变态的windows批处理4.txt

[20171225]变态的windows批处理4.txt

[oracle@hb shell_test]$ cat echo_time 
#!/bin/sh

[20171101]修改oracle口令安全难题.txt

–//明天读书windows 批处理的echo
&.使用它能够兑现类似回车换行的功能.例子:

–//后日学习windows 批处理的echo
&.使用它可以兑现类似回车换行的功用.例子:

一.最简便的调用sqlplus
sqlplus -S “sys/unimas as sysdba” << !
select to_char(sysdate,’yyyy-mm-dd’) today from dual;
exit;
!

–//等保的题材,做一些关于修改oracle口令方面的测试.

1.echo &.
R:\>echo 1111 & echo 2222
1111
2222

1.echo &.
R:\>echo 1111 & echo 2222
1111
2222

[oracle@hb shell_test]$ ./echo_time 

1.oracle修改口令一般如下格局:

–//可是假如写成如下:

–//然而只要写成如下:

TODAY

2011-03-21

-S 是silent
mode,不出口接近“SQL>”,连接数据库,关闭数据库之类的音信。

eof可以是其余字符串
比如”laldf”那么当您输入单独一行laldf时”shell认为输入达成,不过必须代表块开头必须运用<<;
开首和终止要合营这一个标记“<<”后边的始末
举例子:

[oracle@hb shell_test]$ sqlplus -s “sys/unimas as sysdba” <<
abc
> select to_char(sysdate,’yyyy-mm-dd’) today from dual;
> exit;
> abc

alter user scott identified by oracle;
password scott
其三方工具,平日也是实践以上类似的命令.我使用SQL
Tracker(toad自带的工具)测试,实际上执行的也是第1种方式.

R:\>echo 1111 & echo 2222 > aa.txt
1111

R:\>echo 1111 & echo 2222 > aa.txt
1111

TODAY

2011-03-21

二.sqlplus的结果传递给shell的点子一

[oracle@hb shell_test]$ cat test2.sh 
#!/bin/bash
VALUE=`sqlplus -S “test/unimas” << !
set heading off
set feedback off
set pagesize 0
set verify off
set echo off
select to_char(sysdate,’yyyy-mm-dd’) today from dual;
exit
!`
echo $VALUE
if [ -n “$VALUE” ]; then
echo “The rows is $VALUE”
exit 0
else
echo “There is no row”
fi

三.sqlplus的结果传递给shell的章程二

[oracle@hb shell_test]$ cat test1.sh 
#!/bin/bash
sqlplus -S “test/unimas” << !
set heading off
set feedback off
set pagesize 0
set verify off
set echo off
col coun new_value v_coun
select count(*) coun from lesson;
exit v_coun
!
VALUE=”$?”
echo “show row:$VALUE”

col coun new_value v_coun v_coun为number类型。因为exit
只好回到数值类型。

四.把shell参数传递给sqlplus

#【澳门金沙国际】修改oracle口令安全题材。!/bin/bash
t_id=”$1″
sqlplus -S “test/unimas” << !
set heading off
set feedback off
set pagesize 0
set verify off
set echo off
select teachername from teacher where id=$t_id;
exit
!

五.sqlplus的结果存储在文书中

#!/bin/sh
sqlplus -S “test/unimas”<<EOF
set heading off
set feedback off
set pagesize 0
set verify off
set echo off
spool spool_file
SELECT * from teacher;
spool off
exit;
EOF

http://blog.chinaunix.net/space.php?uid=9124312&do=blog&id=181372

 

####################################################################################################################################

查看调度种类状态脚本:

#!/bin/sh

if [[ -z “$1” ]] || [[ “$1” -ne 0 && “$1” -ne 2 ]]       #使用[[ ]] 实行逻辑不通操作
then
    echo “Please input your parameter: query status[0,2]!”
    exit
fi

#for buname in cnlog enlog ItLog JrLog AuLog InnerLog
for buname in cnlog enlog
do
    sqlplus -S ‘etl/etl@dw_testdb’ << abc        #应用 << EOF格局输入音讯     set line 155
    set pages 9999
    SELECT /*+ PARALLEL(a,4) */ * FROM $buname.hla_job_rec a where
status = $1;
    exit
abc
done

2.测试:
–//我自己一度树立一个剧本(我修改参加包蕴alter的始末):
# cat -v Tcpdumpsql
#! /bin/bash
/usr/sbin/tcpdump  -l -i eth0 -s 16384 -A -nn src host $1 and dst port
1521 2>/dev/null |  tee -a /tmp/aa1 |sed -u -e 
“s/^M/!/g;s/^E\.\..\{1,100\}//;s/\.*$//;s/^\.*//” | \
awk ‘{if (tolower($0) ~ “select” || tolower($0) ~ “update” || 
tolower($0) ~ “delete” ||tolower($0) ~ “alter” || tolower($0) ~ “insert”
|| $0 ~ “ORA-” ) {p=1;print} \
else if(p == 1 && $0 !~ “^[0-9][0-9]:”) {print} else if ($0 ~
“^[0-9][0-9]:”) {p=0}}’

R:\>cat aa.txt
2222

R:\>cat aa.txt
2222

–//注:^M 实际上在vi里面要经过ctrl+v ctrl+m输入(windows下ctrl+q
ctrl+m),首即使因为大家付出写PB代码使用~r而尚未加~n,这样
–//在突显时因为没有换行突显内容会被覆盖.

–//你可以窥见1111,呈现输出,而2222写入文件aa.txt,改写成管道看看.

–//你可以窥见1111,突显输出,而2222写入文件aa.txt,改写成管道看看.

3.测试alter user修改口令:
–//在client端登录,执行如下测试命令:
select sysdate from dual;
alter user scott identified by oracle;
select Sysdate from dual;

R:\>echo 1111 &echo 2222 | cat
1111
2222

R:\>echo 1111 &echo 2222 | cat
1111
2222

–//在服务器执行:
# Tcpdumpsql cliend_ip
–//注:client_id换成对应的ip.
select sysdate from dual
%alter user scott identified by oracle
select Sysdate from dual

–//OK.实际上这些是假象,第1行进显示器,第2步履管道,看下边的测试就精晓了.借使要写到文件实际上要加括号,这么些跟linux有一个相似.
R:\>(echo 1111 &echo 2222 ) > aa.txt

–//OK.实际上这几个是假象,第1行进屏幕,第2行进管道,看上面的测试就知道了.如果要写到文件实际上要加括号,这几个跟linux有一个相似.
澳门金沙国际,R:\>(echo 1111 &echo 2222 ) > aa.txt

–//很显然改动口令的一声令下暴露无遗.

R:\>cat aa.txt
1111
2222

R:\>cat aa.txt
1111
2222

4.测试password修改口令:
–//在client端登录,执行如下测试命令:
select sysdate from dual;
password
select Sysdate from dual;

–//那么些倒是正常的情形.

–//那一个倒是正常的情状.

–//在服务器执行:
# Tcpdumpsql cliend_ip
select sysdate from dual
       
………………..SCOTT…..AUTH_SESSKEY……..!…!AUTH_PASSWORD@…@1498887FF997E2D432717C036E8672E9858F261F5A058B6927A9CE4DA137D1AD………AUTH_NEWPASSWORD@…@FD4CD857F51847B1B86CFDC3263776C365CC27A33FACD76763AB40FE3B073052….!…!AUTH_TERMINAL…..IKD84BCP………AUTH_PROGRAM_NM…..sqlplus.exe………AUTH_MACHINE…..WORKGROUP\IKD84BCP………AUTH_PID       
…    
1404:5880………AUTH_SID!…!Administrator………AUTH_ALTER_SESSION……ALTER
SESSION SET NLS_LANGUAGE= ‘AMERICAN’ NLS_TERRITORY= ‘AMERICA’
NLS_CURRENCY= ‘$’ NLS_ISO_CURRENCY= ‘AMERICA’
NLS_NUMERIC_CHARACTERS= ‘.,’ NLS_CALENDAR= ‘GREGORIAN’
NLS_DATE_FORMAT= ‘YYYY-MM-DD HH24:MI:SS’ NLS_DATE_LANGUAGE=
‘AMERICAN’ NLS_SORT= ‘BINA.RY’ TIME_ZONE= ‘+08:00’ NLS_COMP= ‘BINARY’
NLS_DUAL_CURRENCY= ‘$’ NLS_TIME_FORMAT= ‘HH.MI.SSXFF AM’
NLS_TIMESTAMP_FORMAT= ‘YYYY-MM-DD HH24:MI:SS.FF’
NLS_TIME_TZ_FORMAT= ‘HH.MI.SSXFF AM TZR’ NLS_TIMESTAMP_TZ_FORMAT=
‘YYYY-MM-DD HH24:MI:SS.FF TZH:TZM’
select Sysdate from dual

2.采用那一个特点能够透过管道传输命令给sqlplus.

2.应用这几个特性可以经过管道传输命令给sqlplus.

–//做一些格式化处理
………………..SCOTT…..AUTH_SESSKEY……..!…!AUTH_PASSWORD@…@1498887FF997E2D432717C036E8672E9858F261F5A058B6927A9CE4DA137D1AD
………AUTH_NEWPASSWORD@…@FD4CD857F51847B1B86CFDC3263776C365CC27A33FACD76763AB40FE3B073052….!…!AUTH_TERMINAL…..IKD84BCP
………AUTH_PROGRAM_NM…..sqlplus.exe………AUTH_MACHINE…..WORKGROUP\IKD84BCP………AUTH_PID       
…     
1404:5880………AUTH_SID!…!Administrator………AUTH_ALTER_SESSION……ALTER
SESSION SET NLS_LANGUAGE= ‘AMERICAN’
NLS_TERRITORY= ‘AMERICA’ NLS_CURRENCY= ‘$’ NLS_ISO_CURRENCY=
‘AMERICA’ NLS_NUMERIC_CHARACTERS= ‘.,’
NLS_CALENDAR= ‘GREGORIAN’ NLS_DATE_FORMAT= ‘YYYY-MM-DD HH24:MI:SS’
NLS_DATE_LANGUAGE= ‘AMERICAN’ NLS_SORT= ‘BINA.RY’ TIME_ZONE=
‘+08:00’
NLS_COMP= ‘BINARY’ NLS_DUAL_CURRENCY= ‘$’ NLS_TIME_FORMAT=
‘HH.MI.SSXFF AM’ NLS_TIMESTAMP_FORMAT= ‘YYYY-MM-DD HH24:MI:SS.FF’
NLS_TIME_TZ_FORMAT= ‘HH.MI.SSXFF AM TZR’ NLS_TIMESTAMP_TZ_FORMAT=
‘YYYY-MM-DD HH24:MI:SS.FF TZH:TZM’

R:\>echo set timing off head off; &echo select  sysdate  from
dual;
set timing off head off;
select  sysdate  from dual;

R:\>echo set timing off head off; &echo select  sysdate  from
dual;
set timing off head off;
select  sysdate  from dual;

SYS@book> column SPARE4 format a70
SYS@book> select name,password,spare4 from user$ where
name=’SCOTT’;
NAME  PASSWORD                       SPARE4

R:\>echo set timing off head off; &echo select  sysdate  from dual; 
| sqlplus -s scott/book@78
set timing off head off;

R:\>echo set timing off head off; &echo select  sysdate  from dual; 
| sqlplus -s scott/book@78
set timing off head off;


SYSDATE

2017-12-25 10:06:33

–//晕!!明显set timing off head
off;那行没有通过管道出口,而是径直出口到显示器.因为倘使输入管道,显示的应该是从未有过sysdate字段名.
–//仔细看前面的事例才察觉实际上echo 1111 &echo 2222 | cat
输出1111走显示屏,而输出2222管道,看上去突显是例行的.
–//也就是要2行都由此管道必须使用括号.修改如下.

R:\>(echo set timing off head off; &echo select  sysdate  from dual;
) | sqlplus -s scott/book@78
2017-12-25 10:08:59

–//我google发现别的的写法,在&前参预^.
R:\>echo set timing off head off;^&echo select  sysdate  from dual; 
| sqlplus -s scott/book@78
2017-12-25 10:11:57

–//确实是Ok了,不过别的的题材来了:
R:\>echo set timing off head off;^&echo select  sysdate  from dual; 
| cat
set timing off head off;
select  sysdate  from dual;

R:\>echo set timing off head off;^&echo select  sysdate  from dual;
> aa.txt

R:\>cat aa.txt
set timing off head off;&echo select  sysdate  from dual;

–//无法明白windows的批处理,通过管道出口2行.而选择文件吸纳突显的是set
timing off head off;&echo select  sysdate  from dual;
–//重定向到文件时^实际上转义&.
set timing off head off; &echo select  sysdate  from dual;

–//而实际上那样实践是极度的.
R:\>cat aa.txt | sqlplus -s scott/book@78
Enter value for echo:
SP2-0546: User requested Interrupt or EOF detected.

–//仍旧不好领会windows的批处理的神妙!!在自身感到最佳的法子依然加括号相比较好领会一些.
–//实际上假使能很好了解链接
–//就能很好掌握.

–//可是只要echo里面有括号问题又来了:
R:\>(echo set timing off head off;&echo select  (sysdate+1)  from
dual;)  | sqlplus -s scott/book@78
那会儿不应有 from。

–//也就是)要转义,要转义3次.碰着那种情景持续扩大^就是了.
R:\>(echo set timing off head off;&echo select  (sysdate+1^^^)  from
dual;)  | sqlplus -s scott/book@78
2017-12-26 11:16:33

–//而前边那种形式就差不多了.
R:\>echo set timing off head off;^&echo select  (sysdate+1)  from
dual; |   sqlplus -s scott/book@78
2017-12-26 11:17:35

–//在我看来windows批处理真是变态加变态..

SYSDATE

2017-12-25 10:06:33

–//晕!!明显set timing off head
off;那行没有通过管道出口,而是一直出口到显示屏.因为倘若输入管道,展现的相应是一贯不sysdate字段名.
–//仔细看前边的例子才发现实际上echo 1111 &echo 2222 | cat
输出1111走显示器,而输出2222管道,看上去突显是正规的.
–//也就是要2行都通过管道必须使用括号.修改如下.

R:\>(echo set timing off head off; &echo select  sysdate  from dual;
) | sqlplus -s scott/book@78
2017-12-25 10:08:59

–//我google发现其余的写法,在&前投入^.
R:\>echo set timing off head off;^&echo select  sysdate  from dual; 
| sqlplus -s scott/book@78
2017-12-25 10:11:57

–//确实是Ok了,不过别的的题材来了:
R:\>echo set timing off head off;^&echo select  sysdate  from dual; 
| cat
set timing off head off;
select  sysdate  from dual;

R:\>echo set timing off head off;^&echo select  sysdate  from dual;
> aa.txt

R:\>cat aa.txt
set timing off head off;&echo select  sysdate  from dual;

–//不可能领会windows的批处理,通过管道出口2行.而利用文件吸纳突显的是set
timing off head off;&echo select  sysdate  from dual;
–//重定向到文件时^实际上转义&.
set timing off head off; &echo select  sysdate  from dual;

–//而实际上那样实践是很是的.
R:\>cat aa.txt | sqlplus -s scott/book@78
Enter value for echo:
SP2-0546: User requested Interrupt or EOF detected.

–//依然不佳掌握windows的批处理的微妙!!在自己深感最佳的艺术依旧加括号比较好精通一些.
–//实际上假若能很好了解链接
–//就能很好掌握.

–//可是只要echo里面有括号难题又来了:
R:\>(echo set timing off head off;&echo select  (sysdate+1)  from
dual;)  | sqlplus -s scott/book@78
此刻不该 from。

–//也就是)要转义,要转义3次.遭逢那种景况频频追加^就是了.
R:\>(echo set timing off head off;&echo select  (sysdate+1^^^)  from
dual;)  | sqlplus -s scott/book@78
2017-12-26 11:16:33

–//而前边那种办法就概括了.
R:\>echo set timing off head off;^&echo select  (sysdate+1)  from
dual; |   sqlplus -s scott/book@78
2017-12-26 11:17:35

–//在我看来windows批处理真是变态加变态..


SCOTT 0EDE56329E1D82EA              
S:52BD300CE604E12EB9D6731005A8294E77D62C898D4C7CB2827DFCAE90AC

–//从那里看看,改变口令使用password更加安全一些.

相关文章